Method, device and electronic device for automatically generating test cases based on ER diagram

Through the automatic generation of test cases based on ER graph, the problem of needing to rewrite test cases after database structure changes is solved, and the function of no need to rewrite test cases when database changes is realized, reducing the complexity of system maintenance.

CN119739629APending Publication Date: 2025-04-01WUHAN BIG PULP IND DEV CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411725126.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-04-01

AI Technical Summary

Technical Problem

The prior art lacks a method of automatically generating test cases through ER graphs, which leads to the need to rewrite test cases after the database structure changes, which increases the complexity and difficulty of system maintenance.

Method used

Provide a method of automatically generating test cases based on ER graphs. It extracts ER graphs through database tools, analyzes ER graphs to generate data models, defines the rules of test cases based on business logic, and verifies the data model, and generates verification results as test cases.

Benefits of technology

It realizes that when the database structure changes, there is no need to rewrite test cases. You only need to regenerate the ER graph and parse the automatic test cases, which reduces the complexity and difficulty of system maintenance and ensures the correctness of database tables and constraint relationships.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119739629A_ABST
    Figure CN119739629A_ABST
Patent Text Reader

Abstract

The present invention relates to a method, device and electronic device for automatically generating test cases based on ER diagrams, and belongs to the technical field of software automated testing, wherein the method comprises: extracting an initial ER diagram from a target database based on a database tool; parsing the initial ER diagram to obtain a data model; defining rules for generating test cases based on the business logic of an application corresponding to the target database; verifying the data model based on the rules to obtain a verification result, and using the verification result as a test case. The present invention converts the target database directly into an ER diagram, thereby parsing the ER diagram to obtain a data model, thereby automatically generating test cases. When the database is changed, there is no need to rewrite the test cases, only the ER diagram needs to be regenerated according to the database, and the ER diagram needs to be parsed to automatically generate test cases.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software automated testing, and in particular to a method, a device and an electronic device for automatically generating test cases based on an ER diagram. Background Art

[0002] ER diagram (Entity-Relationship Diagram) is used to define and describe the structure of a database. It represents the logical structure of a database through entities (tables), attributes (fields), and relationships (connections). ER diagrams clearly define the relationships and constraints between tables in a database.

[0003] As the system evolves and requirements change, the database structure will be adjusted. These changes may include adding new tables, modifying existing table structures, adding or removing fields, changing data types, updating constraints, etc. Each change may introduce new errors or break existing functions, increasing the complexity and maintenance difficulty of the system. Database changes may affect the integrity and consistency of data. For example, adding a foreign key constraint requires ensuring that all referenced data exists, while deleting or modifying the table structure may result in data loss or inconsistency. These constraints need to be verified after the change to prevent data quality issues. In addition, after each database structure change, comprehensive regression testing is required to ensure the compatibility of the new structure with existing applications and prevent new changes from causing old problems.

[0004] In summary, the prior art lacks a method for automatically generating test cases through ER to solve the problem of needing to rewrite test cases due to database changes in the prior art. Summary of the invention

[0005] In view of this, it is necessary to provide a method, device and electronic device for automatically generating test cases based on ER diagrams, so as to solve the problem of the need to rewrite test cases due to database changes in the prior art.

[0006] In order to solve the above problems, the present invention provides a method for automatically generating test cases based on ER diagrams, comprising: Extract the initial ER diagram from the target database based on database tools; Parsing the initial ER diagram to obtain a data model; Define rules for generating test cases based on the business logic of the application corresponding to the target database; The data model is verified based on the rules to obtain a verification result, which is used as a test case.

[0007] In a possible implementation, the database tool includes: one or more of DBeaver, Navicat, MySQLWorkbench, ER / Studio and DBDesigner.

[0008] In a possible implementation, the parsing the initial ER diagram to generate a data model includes: Standardizing the initial ER diagram to obtain a first ER diagram; De-noising the first ER diagram to obtain a second ER diagram; Identify the lines and borders in the second ER diagram based on an edge detection algorithm to obtain a third ER diagram; Identify the third ER diagram based on the connected domain analysis technology to obtain a fourth ER diagram containing text areas of entity names, attribute names, and relationship types between entities; Extracting entity names, attribute names, and relationship types between entities in the fourth ER diagram; A data model is constructed based on the entity names, the attribute names, and the relationship types between the entities.

[0009] In a possible implementation, the relationship types between entities include: a first relationship between entities and a second relationship between entities: The first relationship between the entities includes: a generalization relationship between entities, a combination relationship between entities, an association relationship between entities, a dependency relationship between entities, and an aggregation relationship between entities; The second relationship between entities includes: a one-to-one relationship between entities, a one-to-many relationship between entities, and a many-to-many relationship between entities.

[0010] In a possible implementation manner, the rule includes: one or more of a basic attribute verification rule, a relationship verification rule, and a constraint verification rule.

[0011] In a possible implementation manner, the verifying the data model based on the rule includes: Verifying the uniqueness of the primary key in the data model based on basic attribute verification rules; Verifying a one-to-many relationship, a many-to-many relationship, or a many-to-one relationship between entities in the data model based on a relationship verification rule; The combined uniqueness between entities in the data model is verified based on the constraint verification rules.

[0012] In a possible implementation, the method further includes: executing the test case based on an automated testing framework to verify whether the test case meets expectations.

[0013] On the other hand, the present invention also provides a device for automatically generating test cases based on ER diagrams, comprising: ER diagram acquisition module, used to extract ER diagram from the target database based on database tools; A data model acquisition module, used for parsing the ER diagram to obtain a data model; A rule generation module, used to define rules for generating test cases based on the business logic of the application corresponding to the target database; The test case acquisition module is used to verify the data model based on the rules, obtain the verification result, and use the verification result as a test case.

[0014] On the other hand, the present invention also provides an electronic device, including a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in a method for automatically generating test cases based on ER diagrams described in any one of the above implementations.

[0015] On the other hand, the present invention also provides a computer-readable storage medium for storing computer-readable programs or instructions, which, when executed by a processor, can implement the steps in a method for automatically generating test cases based on ER diagrams described in any of the above-mentioned implementation methods.

[0016] The beneficial effects of the present invention are as follows: the present invention provides a method for automatically generating test cases based on ER diagrams, firstly extracting ER diagrams from target databases based on database tools, parsing the ER diagrams to obtain data models, thereby expressing the fields of various tables in the database and the relationships between tables in the form of images, defining rules for generating test cases based on the business logic of the application corresponding to the target database, verifying the data model based on the rules, obtaining verification results, ensuring that the tables and table fields in the database and various constraint relationships are all correct, and using the verification results as test cases. The present invention converts the target database directly into an ER diagram, thereby parsing the ER diagram to obtain a data model, thereby automatically generating test cases. When the database is changed, there is no need to rewrite the test cases, only the ER diagram needs to be regenerated according to the database, and the ER diagram needs to be parsed to automatically generate test cases. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 A flowchart of an embodiment of a method for automatically generating test cases based on an ER diagram provided by the present invention; Figure 2 For the present invention Figure 1A schematic flow chart of an embodiment of S102; Figure 3 For the present invention Figure 1 A schematic flow chart of an embodiment of S104; Figure 4 A schematic flow chart of an embodiment of a device for automatically generating test cases based on ER diagrams provided by the present invention; Figure 5 A schematic structural diagram of an embodiment of an electronic device provided by the present invention. DETAILED DESCRIPTION

[0018] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.

[0019] Before presenting the embodiments, the following terms are explained.

[0020] ER diagram, full name Entity Relationship Diagram, is a graphical representation method used to describe entities in a database and the relationships between them. ER diagram contains three basic components: entities, relationships, and attributes. Entities are usually represented by rectangular boxes, relationships by diamond boxes, attributes by ovals or rounded rectangles, and entities (or relationships) and their attributes are connected by straight lines. ER diagrams help users and database designers understand and build data models in a graphical way, and are an important tool in database design.

[0021] Entity: A table in a database that represents an object or concept that can store data.

[0022] Attribute: A field of an entity that represents a specific feature or data of the entity.

[0023] Relationship: The association between entities.

[0024] Primary Key: A field or combination of fields that uniquely identifies each row in a table. Primary key values ​​must be unique and cannot be null.

[0025] Foreign Key: A field used to establish a link between tables, whose value references the primary key of another table.

[0026] Constraint: A rule used to restrict data in a table.

[0027] The present invention provides a method, device and electronic device for automatically generating test cases based on ER diagrams, which are described below respectively.

[0028] Figure 1 A flow chart of an embodiment of a method for automatically generating test cases based on ER diagrams provided by the present invention is shown as follows: Figure 1 As shown, the method for automatically generating test cases based on ER diagram includes: S101, extracting the initial ER diagram from the target database based on database tools; S102, parsing the initial ER diagram to obtain a data model; S103, defining rules for generating test cases based on the business logic of the application corresponding to the target database; S104: Verify the data model based on the rules to obtain a verification result, and use the verification result as a test case.

[0029] Compared with the prior art, the present embodiment provides a method for automatically generating test cases based on ER diagrams. First, an ER diagram is extracted from a target database based on a database tool, and the ER diagram is parsed to obtain a data model, so that the fields of each table in the database and the relationship between the tables are expressed in the form of an image. A rule for generating test cases is defined based on the business logic of an application corresponding to the target database, and the data model is verified based on the rule to obtain a verification result to ensure that the tables and table fields in the database and various constraint relationships are kept correct, and the verification result is used as a test case. The present invention converts the target database directly into an ER diagram, thereby parsing the ER diagram to obtain a data model, thereby automatically generating test cases. When the database is changed, there is no need to rewrite the test cases, only the ER diagram needs to be regenerated according to the database, and the ER diagram needs to be parsed to automatically generate test cases.

[0030] It should be noted that the database type of this embodiment may be a relational database or a non-relational database, or may be other types of databases.

[0031] In some embodiments of the present invention, the database tool includes: one or more of DBeaver, Navicat, MySQLWorkbench, ER / Studio and DBDesigner.

[0032] In a specific embodiment of the present invention, for example, Navicat is used to extract an ER diagram from a target database, and the specific steps are as follows: Step 1: Open Navicat and connect to the target database.

[0033] Step 2: Select the database for which you want to generate an ER diagram in the database list, and then double-click to open it.

[0034] Step 3: In the table view interface, select the table for which you want to generate the ER relationship diagram and double-click to open the table view interface.

[0035] Step 4: In the ER view, you can see the relationship lines between tables and information such as table attributes and indexes.

[0036] Step 5: You can export the ER diagram to PDF, SVG or PNG format.

[0037] In some embodiments of the present invention, in step S102, as Figure 2 As shown, the parsing of the initial ER diagram to generate a data model includes: S201, standardize the initial ER diagram to obtain a first ER diagram; S202, performing noise removal on the first ER diagram to obtain a second ER diagram; S203, identifying the lines and frames in the second ER diagram based on an edge detection algorithm to obtain a third ER diagram; S204, identifying the third ER diagram based on the connected domain analysis technology to obtain a fourth ER diagram containing text areas of entity names, attribute names, and relationship types between entities; S205, extracting entity names, attribute names, and relationship types between entities in the fourth ER diagram; S206: Construct a data model based on the entity names, the attribute names, and the relationship types between the entities.

[0038] In a specific embodiment of the present invention, parsing the initial ER diagram to generate a data model specifically includes the following steps: Step 1: Standardize the ER diagram and adjust the resolution, contrast, brightness, etc. to ensure image clarity; Step 2: Use image processing technology to remove noise in the image, making entities, attributes and connecting lines more prominent; Step 3: Use edge detection algorithms to identify lines and borders in the ER diagram, which represent entity boundaries and relationship lines; Step 4: Use the connected domain analysis technique to identify and segment the text regions containing entity names, attribute names, and relationship types; Step 5: Use OCR technology to identify the segmented text area and convert it into processable text information. Extract entity names, attribute names, and relationship types. For example: a) Rectangular frame: entity b) Ellipse: attribute c) Diamond: Relationship d) Double rectangle: weak entity e) Oval (underlined): primary key f) Multiple ellipses extended from an ellipse using lines: composite attribute g) Circle: Constraints Step 6: Determine the relationship between entities by analyzing the entities connected by lines. Use the geometric features of the graphics (endpoint coordinates) to match the entity box and the line to determine the relationship type (one-to-one, one-to-many, many-to-many) Step 7: Associate the attribute name with the corresponding entity based on the positional relationship of the text area.

[0039] Step 8: Create entity classes based on the identified entity names and attributes. Each entity class contains a list of its attributes. Step 9: Create a relationship object based on the identified relationship type and the entities involved, and record the entities at both ends of the relationship and the nature of the relationship. For example: a) The text in the rectangular box is the name of the entity; b) The text in the oval is the name of the attribute. If the oval is underlined, the constraint of the attribute is "PRIMARY KEY". c) The text in the diamond is the name of the relationship; d) The text in the double rectangle is the name of the weak entity; Step 10: Organize the above entities and relationship objects into an abstract data model and encode it into a data structure in JSON format to facilitate subsequent processing and test case generation. Specifically, in this embodiment, the code of the data model is as follows: { "entities":[ { "name": "User", "attributes":[ {"name":"userId","primary": true}, {"name":"email"}, {"name":"passwordHash"}, {"name":"role"}, {"name":"joinDate"} ], "relationships":[ {"entity":"Profile","type":"hasOne"}, {"entity":"PaymentInfo","type":"hasOne"} ] }, { "name":"Profile", "attributes":[ {"name":"profileId""primary":true}, {"name":"firstName"}, {"name":"lastName"}, {"name":"aboutMe"}, {"name":"avatarUrl"}, {"name":"userId"} ] }, { "name":"Course", "attributes":[ {"name":"courseId","primary":true}, {"name":"title"}, {"name":"description"}, {"name":"creationDate"}, {"name":"instructorId"} ], "relationships":[ {"entity":"Enrollment","type":"hasMany"}, {"entity":"Exam","type":"hasMany"} ] }, { "name":"Enrollment", "attributes":[ {"name":"enrollmentId","primary":true}, {"name":"studentId"}, {"name":"courseId"}, {"name":"enrollmentDate"} ] }, { "name": "Exam", "attributes":[ {"name":"examId","primary":true}, {"name":"courseId"}, {"name":"title"}, {"name":"startDate"}, {"name":"endDate"} ], "relationships":[ {"entity":"Question","type":"hasMany"} ] }, { "name":"Enrollment", "attributes":[ {"name":"enrollmentId","primary":true}, {"name":"studentId"}, {"name":"courseId"}, {"name":"enrollmentDate"} ] }, { "name":"Exam", "attributes":[ {"name":"examId","primary": true}, {"name":"courseId"}, {"name":"title"}, {"name":"startDate"}, {"name":"endDate"} ], "relationships":[ {"entity":"Question","type":"hasMany"} ] }, { "name":"Question", "attributes":[ {"name":"questionId","primary":true}, {"name":"examId"}, {"name":"content"}, {"name":"type"}, {"name":"marks"} ] }, { "name":"PaymentInfo", "attributes":[ {"name": "paymentId","primary":true}, {"name":"userId"}, {"name":"cardNumber"}, {"name":"expiryDate"}, {"name":"cvv"}, {"name":"billingAddress"}, {"name":"isDefault"} ] } ], "constraints":[ {"type":"CHECK","onEntity":"User","expression":"length(passwordHash)>6"}, {"type":"UNIQUE","onEntity":"Profile","columns":["firstName","lastName"]} ] } In some embodiments of the present invention, the relationship types between entities include: a first relationship between entities and a second relationship between entities: The first relationship between the entities includes: a generalization relationship between entities, a combination relationship between entities, an association relationship between entities, a dependency relationship between entities, and an aggregation relationship between entities; The second relationship between entities includes: a one-to-one relationship between entities, a one-to-many relationship between entities, and a many-to-many relationship between entities.

[0040] In some embodiments of the present invention, the rules include: one or more of basic attribute verification rules, relationship verification rules, and constraint verification rules.

[0041] In some embodiments of the present invention, rules for generating test cases are defined based on actual business logic and requirements, including basic attribute verification, relationship verification, constraint verification, etc. Pseudo code example: defgenerate_test_case(er_model): test_cases=[]#Test cases #Basic attribute verification for entity in er_model["entities"]: for attribute in entity["attributes"]: if attribute.get("primary"): test_cases.append(f"fVerify the uniqueness of the primary key {attribute['name']} of {entity['name']}") # Relationship Verification for entity in er_model["entities"]: for relationship in entity. get("relationships", []): related__entity = relationship["entity"] if relationship["type"] == "has0ne'": test_cases.append(f"Verify the one-to-many relationship between {entity['name]} and {related_entity}") # Constraint Validation for constraint in er_ model.get("constraints", []): if constraint["type"] == "CHECK": test__cases.append(f"Verify the constraint conditions of {constraint[' onEntity']}{constraint ['expression']}") elif constraint["type"] == "UNIQUE": test_ cases.append(f"Verify the uniqueness of the combination of {',.join(constraint['columns'1])} of {constraint['onEntity']}" ) return test_cases In some embodiments of the present invention, in step S104, Figure 3 As shown, the verifying the data model based on the rule includes: S301, verifying the uniqueness of the primary key in the data model based on basic attribute verification rules; S302, verifying the one-to-many relationship, many-to-many relationship, or many-to-one relationship between entities in the data model based on the relationship verification rule; S303: Verify the combined uniqueness between entities in the data model based on constraint verification rules.

[0042] In some embodiments of the present invention, the method further includes: executing the test case based on an automated testing framework to verify whether the test case meets expectations.

[0043] In a specific embodiment of the present invention, an automated testing framework (such as Python's pytest) is used to execute the generated test cases to verify whether the test results meet expectations and check whether all constraints and business logic are correctly processed. The pytest test is integrated into the CI / CD process, such as adding a step in Jenkins or other tools to run the pytest command. This allows all tests to be executed automatically to ensure quality. The specific code is as follows: #tests.py import pytest # Define a function to generate test data def generate_test_cases(num_cases): return test_data #Generate test data and execute the test test_data = generate_test_cases(10) #Basic attribute verification def test_entity_attribute(entity, attribute, value, expected): #Relationship Verification def test_entity_relationship(entity, attribute, value, expected): #Constraint verification def validate_constraint(entity, attribute, value): It should be noted that the database is dynamic. Over time, new tables may be added, and old tables may be deleted or modified. Therefore, maintaining and updating the ER diagram is an ongoing process. Use the synchronization function of the database design tool to automatically update the ER diagram according to the latest database schema to ensure that it always reflects the current database status. Integrate test cases into the continuous integration environment to ensure that tests are automatically executed after each database change.

[0044] In order to better implement a method for automatically generating test cases based on an ER diagram in an embodiment of the present invention, based on a method for automatically generating test cases based on an ER diagram, correspondingly, as follows Figure 4 As shown, an embodiment of the present invention further provides a device for automatically generating test cases based on an ER diagram. A device 400 for automatically generating test cases based on an ER diagram includes: An ER diagram acquisition module 401 is used to extract an initial ER diagram from a target database based on a database tool; A data model acquisition module 402 is used to parse the initial ER diagram to obtain a data model; A rule generation module 403, used to define rules for generating test cases based on the business logic of the application corresponding to the target database; The test case acquisition module 404 is used to verify the data model based on the rules, obtain verification results, and use the verification results as test cases.

[0045] The device 400 for automatically generating test cases based on ER diagrams provided in the above embodiment can implement the technical solution described in the above embodiment of a method for automatically generating test cases based on ER diagrams. The specific implementation principles of the above modules or units can refer to the corresponding contents in the above embodiment of a method for automatically generating test cases based on ER diagrams, which will not be repeated here.

[0046] like Figure 5 As shown, the present invention also provides an electronic device 500. The electronic device 500 includes a processor 501, a memory 502 and a display 503. Figure 5 Only some components of the electronic device 500 are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0047] In some embodiments, the processor 501 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run program codes or process data stored in the memory 502, such as a method for automatically generating test cases based on ER diagrams in the present invention.

[0048] In some embodiments, the processor 501 may be a single server or a server group. The server group may be centralized or distributed. In some embodiments, the processor 501 may be local or remote. In some embodiments, the processor 501 may be implemented in a cloud platform. In some embodiments, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, an internal cloud, a multi-cloud, etc., or any combination thereof.

[0049] In some embodiments, the memory 502 may be an internal storage unit of the electronic device 500, such as a hard disk or memory of the electronic device 500. In other embodiments, the memory 502 may also be an external storage device of the electronic device 500, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 500.

[0050] Furthermore, the memory 502 may include both an internal storage unit of the electronic device 500 and an external storage device. The memory 502 is used to store application software installed in the electronic device 500 and various data.

[0051] In some embodiments, the display 503 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 503 is used to display information on the electronic device 500 and to display a visual user interface. The components 501-503 of the electronic device 500 communicate with each other via a system bus.

[0052] In one embodiment, when the processor 501 executes a program for automatically generating test cases based on an ER diagram in the memory 502, the following steps may be implemented: Extract the initial ER diagram from the target database based on database tools; Parsing the initial ER diagram to obtain a data model; Define rules for generating test cases based on the business logic of the application corresponding to the target database; The data model is verified based on the rules to obtain a verification result, which is used as a test case.

[0053] It should be understood that: when the processor 501 executes a program for automatically generating test cases based on ER diagrams in the memory 502, in addition to the above functions, other functions can also be implemented. For details, please refer to the description of the corresponding method embodiment above.

[0054] Furthermore, the embodiment of the present invention does not specifically limit the type of the electronic device 500 mentioned, and the electronic device 500 may be a portable electronic device such as a mobile phone, a tablet computer, a personal digital assistant (PDA), a wearable device, a laptop computer, etc. Exemplary embodiments of portable electronic devices include but are not limited to portable electronic devices equipped with IOS, Android, Microsoft or other operating systems. The above-mentioned portable electronic devices may also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments of the present invention, the electronic device 500 may not be a portable electronic device, but a desktop computer with a touch-sensitive surface (e.g., a touch panel).

[0055] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.

[0056] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.

Claims

1. A method for automatically generating test cases based on ER diagram, characterized in that: include: Extract the initial ER diagram from the target database based on database tools; Parsing the initial ER diagram to obtain a data model; Define rules for generating test cases based on the business logic of the application corresponding to the target database; The data model is verified based on the rules to obtain a verification result, which is used as a test case.

2. The method for automatically generating test cases based on ER diagram according to claim 1, characterized in that: The database tools include: one or more of DBeaver, Navicat, MySQL Workbench, ER / Studio and DBDesigner.

3. The method for automatically generating test cases based on ER diagram according to claim 1, characterized in that: The step of parsing the initial ER diagram to obtain a data model includes: Standardizing the initial ER diagram to obtain a first ER diagram; De-noising the first ER diagram to obtain a second ER diagram; Identify the lines and borders in the second ER diagram based on an edge detection algorithm to obtain a third ER diagram; Identify the third ER diagram based on the connected domain analysis technology to obtain a fourth ER diagram containing text areas of entity names, attribute names, and relationship types between entities; Extracting entity names, attribute names, and relationship types between entities in the fourth ER diagram; A data model is constructed based on the entity names, the attribute names, and the relationship types between the entities.

4. The method for automatically generating test cases based on ER diagram according to claim 3 is characterized in that: The relationship types between entities include: a first relationship between entities and a second relationship between entities: The first relationship between the entities includes: a generalization relationship between entities, a combination relationship between entities, an association relationship between entities, a dependency relationship between entities, and an aggregation relationship between entities; The second relationship between entities includes: a one-to-one relationship between entities, a one-to-many relationship between entities, and a many-to-many relationship between entities.

5. The method for automatically generating test cases based on ER diagram according to claim 1, characterized in that: The rules include: one or more of basic attribute verification rules, relationship verification rules and constraint verification rules.

6. The method for automatically generating test cases based on ER diagram according to claim 5, characterized in that: The verifying the data model based on the rule includes: Verifying the uniqueness of the primary key in the data model based on basic attribute verification rules; Verifying a one-to-many relationship, a many-to-many relationship, or a many-to-one relationship between entities in the data model based on a relationship verification rule; The combined uniqueness between entities in the data model is verified based on the constraint verification rules.

7. The method for automatically generating test cases based on ER diagram according to claim 1, characterized in that: Also includes: The test cases are executed based on an automated testing framework to verify whether the test cases meet expectations.

8. A device for automatically generating test cases based on ER diagram, characterized in that: include: ER diagram acquisition module, used to extract the initial ER diagram from the target database based on database tools; A data model acquisition module, used for parsing the initial ER diagram to obtain a data model; A rule generation module, used to define rules for generating test cases based on the business logic of the application corresponding to the target database; The test case acquisition module is used to verify the data model based on the rules, obtain the verification result, and use the verification result as the test case.

9. An electronic device, characterized in that: comprising a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in the method for automatically generating test cases based on ER diagrams as described in any one of claims 1 to 7 above.

10. A computer-readable storage medium, characterized in that: Used to store computer-readable programs or instructions, which, when executed by a processor, can implement the steps in a method for automatically generating test cases based on ER diagrams as described in any one of claims 1 to 7.