Method and system for automatically generating test data and application

Through the method of automatically generating test data, the problems of low efficiency and incomplete coverage of manually generated test data are solved, data consistency and coverage are achieved, it is suitable for the testing requirements of complex software systems, and the testing efficiency and accuracy are improved.

CN118760595APending Publication Date: 2024-10-11YUE JIN SHU ZI KE JI (SHANG HAI) GU FEN YOU XIAN GONG SI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410858096.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-28
Publication Date
2024-10-11

AI Technical Summary

Technical Problem

The existing technology of manually generating test data in software testing has low efficiency, incomplete coverage, poor consistency, and difficulty in maintenance. Automated tools have limited applicability, insufficient flexibility, low automation, and weak integration, making it difficult to meet complex and diverse tests. need.

Method used

Provide a method to automatically generate test data, process original data through templates, generate basic test data according to test methods, and generate forward and conditional data. Complete test data is formed through hierarchical splicing and logical processing to ensure data consistency and coverage. , supporting comprehensive test coverage and analysis.

Benefits of technology

It improves the efficiency and accuracy of test data generation, reduces manual intervention and maintenance costs, is suitable for the testing needs of various software systems, and realizes automatic generation and management of data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure BDA0004918575690000071
    Figure BDA0004918575690000071
  • Figure BDA0004918575690000081
    Figure BDA0004918575690000081
  • Figure BDA0004918575690000091
    Figure BDA0004918575690000091
Patent Text Reader

Abstract

The invention discloses a method for automatically generating test data. The method comprises the following steps: reading a file list and content, adjusting data content in a file and storing the data content into an original data table of a database; performing duplicate removal on the data of the original data table to generate corresponding test data, and storing the generated test data into a database basic test data table; according to the step of generating the basic test data, generating corresponding data of the test data; filtering out the condition data of the test data and the condition data of the corresponding data, generating the condition data of the test data and the condition data of the corresponding data, preparing a default data table, splicing the data, and outputting the data to a result data table; acquiring data of the basic test data table according to the hierarchy, splicing the data with the result data, judging whether the data triggers a condition or not, and performing circular processing; sorting and separating result data, generating and executing SQL statements, and inserting the SQL statements into a database to complete data production. The invention further discloses a system and application for implementing the method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of test data generation, and relates to a method, system and application for automatically generating test data. Background Art

[0002] With the increasing requirements for data quality, software testing is becoming more and more important in various industries. Currently, in many application scenarios, the generation of test data relies on manual operations by testers, which has many problems and shortcomings:

[0003] Inefficiency: Manually writing test data is a time-consuming and labor-intensive task, especially when faced with large-scale and complex data sets. Testers need to spend a lot of time and energy to write, verify, and maintain test data, which affects the progress and cost of the project.

[0004] Incomplete coverage: Due to the varying abilities and experience of testers, manually generated test data often has incomplete coverage. Certain boundary conditions, abnormal situations, or specific scenarios may be ignored, resulting in the test data being unable to fully cover all functions and features of the system, which in turn affects software quality.

[0005] Poor consistency: Manually generated test data is easily affected by human factors, resulting in the inability to ensure data consistency and reliability. In team collaboration, data written by different testers may have inconsistent formats and field names, which increases the complexity of test data management.

[0006] Difficult to maintain: As the system continues to evolve and requirements change, test data also needs to be updated and maintained accordingly. Manual maintenance of test data is not only labor-intensive but also prone to errors, making it difficult to ensure the timeliness and accuracy of the data.

[0007] Although some existing automated test data generation tools have alleviated the above problems to a certain extent, they still have the following shortcomings:

[0008] Limited applicability: Existing tools are often targeted at specific types of data or specific test scenarios, and are difficult to adapt to various complex and diverse testing needs. The compatibility and adaptability of different systems, different data structures, and different test methods are poor, which limits their scope of application.

[0009] Insufficient flexibility: Many tools lack sufficient flexibility and cannot be customized according to the specific needs of users. It is difficult for testers to flexibly configure the test data generation rules and strategies according to actual conditions, resulting in an inflexible and inefficient test data generation process.

[0010] Low degree of automation: Although some tools provide a certain degree of automation, manual intervention is still required in data cleaning, conversion, and verification. The degree of automation is not high, and it is difficult to achieve full-process automated test data generation.

[0011] Weak integration: Existing tools have poor integration with other test tools and systems, making it difficult to form a complete test automation solution. The generation, management, and use of test data cannot be seamlessly connected, affecting test efficiency and effectiveness.

[0012] Therefore, there is an urgent need for a method that can automatically generate large amounts of test data. Summary of the invention

[0013] In order to solve the deficiencies in the prior art, the purpose of the present invention is to provide a method, system and application for automatically generating test data. Through the method of the present invention, automatic generation of test data can be achieved, covering various test scenarios, ensuring data consistency and reliability, improving test efficiency, reducing manual intervention and maintenance costs, and being applicable to the test requirements of various software systems.

[0014] The present invention provides a method for automatically generating test data, which can flexibly generate test data that meets the requirements according to specific test requirements and scenarios, thereby supporting comprehensive test coverage and accurate test analysis. The method comprises the following steps:

[0015] Step 1: Generate original data according to the template: clear the original data table data, read the file list, read the file content, convert the Chinese field names in some fields in the file data into corresponding English field names, convert the Chinese content of some fields into English content, and capitalize the English content of some fields, adjust the data content and store it in the original data table of the database;

[0016] Step 2: Generate basic test data according to the test method in the data: clear the data in the basic test data table, deduplicate the data in the original data table, generate corresponding test data according to different test methods and test types, and then classify and process the data by field type, and store the generated test data (including positive and negative data) into the basic test data table of the database according to the field hierarchy in the original data table of the database;

[0017] Step 3: Generate corresponding data of test data: Generate corresponding data of the positive direction of test data according to the steps of generating basic test data in step 2 (do not clear the basic test data, only keep the positive data);

[0018] Step 4, generate conditional data of test data and conditional data of corresponding data: generate conditional data of test data according to the steps of basic test data in step 2 (do not clear the basic test data), and generate positive conditional data of corresponding data according to the steps of basic test data in step 3 (do not clear the basic test data, only keep positive data);

[0019] In the present invention, the corresponding data is the corresponding data of the test data;

[0020] Step 5: Generate complete data: exclude conditional data from the generated test data, adjust and obtain the required content, prepare the default data table, connect according to the system table name and field name, form complete data, and output it to the result data table;

[0021] Step 6: Splice the conditional data: obtain the data of the same level in the basic test data table according to the level, and splice it with the result data in the result data table to determine whether the spliced ​​data triggers the condition. If the splicing is successful, replace the same field of the result data with the test data. If it is unsuccessful, splice the test data and the default data table to form a complete result data, and then perform logical analysis on the result data to generate the expected new result data. After processing, delete the lower-level result data and perform the loop processing again until all levels are processed.

[0022] Step 7: Process the final results: sort and separate the result data, generate and execute SQL statements, and finally insert them into the database to complete the production of the test data.

[0023] In step 1, the data consistency in the test data generation process is ensured by clearing the data in the original data table; the file list reading supports reading one or more imported files at the same time, and stores the content in the original data table of the database after reading the file;

[0024] Convert the data including test methods and verification conditions from Chinese to English (including field names and specific contents, etc.), and capitalize the verification table, verification field, verification condition table, verification condition field, verification correspondence table, verification corresponding field, verification correspondence table condition table, and verification correspondence table condition field;

[0025] For data containing backslashes, add another backslash symbol so that the backslash can be understood correctly.

[0026] In step 2, the data in the basic test data table is cleared to initialize the data, ensuring that the previous data is cleared, and then the data to be tested is obtained from the original data table; the data is deduplicated to ensure that the result data of each field is unique;

[0027] Classify the data according to the comparative or relational test type in the original data table; use the test method range table to obtain the default test value according to the determined test type; subdivide the data according to the field type of numeric, date, and character; generate test data for the basic test data table based on the test type and field type, set the field level to 1 and save the results to the basic test data table.

[0028] In step 3: the corresponding data in the original data table, according to the relevant conditions of step 2, is the corresponding data of the test data, and the test method of the corresponding data is limited to relational. Then, according to the test method and test data, only positive test data is generated and stored in the basic test data table, and the level of the field is set to obtain the level of the original test table according to the basic test data table * 2;

[0029] In step 4, the forward data and reverse data in the conditional data in the original data table and the conditional data of the corresponding data in the original data table are opposite to the results of the forward data and reverse data in step 2. Specifically, the forward result of step 2 is the data that meets the test conditions, and the reverse result is the data that does not meet the conditions; while the forward result of step 4 is the data that does not meet the conditions, and the reverse result is the data that meets the conditions. The field level setting of the conditional data is based on the basic test data table to obtain the level of the original test table * 2 + 1. Similarly, the generation of the conditional data of the corresponding data in step 4 only generates forward data, and does not generate reverse data. The level of the set field is used as the basis, and the results are saved in the basic test table.

[0030] Specifically, if there is conditional data, it is also necessary to generate the conditional data and the conditional data of the corresponding table: obtain data from the original test table, remove duplicates and classify data types. Similarly, the conditional data of the test data generates forward and reverse data, and the conditional data of the corresponding data generates forward data. The result logic of the conditional data of the two tables is opposite to the previous result logic. The field level setting of the corresponding data is based on the data level generated by the basic test data multiplied by 2+1, and the result is saved in the basic test data table.

[0031] In step five, after generating the test data of the corresponding basic test data table, it is necessary to process the non-test data to complete the overall matching of the data. First, obtain the test data of the completed basic test data table and exclude the data used as conditions, which will be used in subsequent steps. Then, adjust the data content and extract the required fields. Next, prepare a default data table, connect it according to the system table name and field name, form a complete data record, and replace the data to be tested with the test data. Finally, the complete data formed will be output to the result data table, and the maximum number of levels of the basic test data table will be recorded.

[0032] In step six, the basic test data table is obtained according to the level, and is spliced ​​with the result data in the result data table; the splicing result is checked, if the splicing is successful, it means that the result data table already has data, then it is directly obtained, otherwise it is spliced ​​with the default data table to ensure data integrity; based on the newly added data, it is determined whether it triggers the condition, and the judgment is made based on the logical conditions of "and" or "or"; the levels are processed through a loop structure, starting from level 1, each time the loop level + 1, the bottom level is deleted and the upper level is generated, until all levels are processed, and finally only the result data of the largest level is retained.

[0033] In step seven, the result data in the result data table are sorted, and then the fields and specific values ​​in the result data in the result data table are separated while retaining the expected results of the test; the specific values ​​and fields are spliced ​​into corresponding SQL statements, and these SQL statements are executed to insert the data to be tested into the corresponding final database, completing the entire work of producing the data to be tested.

[0034] The present invention also provides a test data automatic generation system, the system comprising: a memory and a processor; a computer program is stored in the memory, and when the computer program is executed by the processor, the above method is implemented.

[0035] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above method is implemented.

[0036] The present invention also provides the above-mentioned method for automatically generating test data, the above-mentioned system for automatically generating test data, or the above-mentioned computer-readable storage medium for use in data verification of various systems, especially in quality verification of data submitted in accordance with regulatory requirements.

[0037] The beneficial effects of the present invention include: this invention describes a method for how to automatically produce test data, and can automatically generate all the test data of the data through a piece of data. At present, testers rely on manual data production, which is inefficient, and there may be omissions in the production of data, and the consistency of data production cannot be well controlled. If the test omission is found, the test method can be quickly supplemented, so that all the test data can be regenerated, which improves the test efficiency, and through the continuous iteration of the test method, a considerable number of good test methods can be effectively retained, which also improves the ability of the testers themselves, and avoids the problem of inadequate analysis and failure to ensure software quality due to personnel loss. And the data are structured and formulated, which is of great help to understand the verification rules and analyze the verification rules. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.

[0039] Figure 1 It is a flow chart of the test data automatic generation method of the present invention.

[0040] Figure 2 It is a schematic diagram of the data flow of the present invention according to the template.

[0041] Figure 3 The present invention generates a basic test data flow chart according to the test method in the data.

[0042] Figure 4 It is a schematic diagram of the corresponding data flow of the present invention for generating test data.

[0043] Figure 5 It is the conditional data for generating test data and corresponding data, and it is necessary to generate a corresponding table-result data flow diagram.

[0044] Figure 6 It is a schematic diagram of a complete data flow generated by the present invention.

[0045] Figure 7 The present invention splices basic data, result data and default data, and is a flow chart of logical processing.

[0046] Figure 8 It is a schematic diagram of the process of merging and inserting data into a database according to the present invention.

[0047] Fig. 9 It is a schematic diagram of the test scenario of the present invention.

[0048] Fig.10 It is a schematic diagram of the results in logical example 1 of the present invention.

[0049] Fig.11 It is a schematic diagram of the results in logical example 2 of the present invention.

[0050] Fig.12 It is a schematic diagram of the results in logical example 3 of the present invention. DETAILED DESCRIPTION

[0051] The present invention is further described in detail with reference to the following specific examples and drawings. The process, conditions, experimental methods, etc. for implementing the present invention, except for the contents specifically mentioned below, are all common knowledge and common common sense in the art and are not particularly limited by the present invention.

[0052] The present invention provides a method for automatically generating test data, such as Figure 1 As shown: read the file list and content, pre-process the data and unify it, adjust the data content and store it in the original data table of the database; deduplicate the data in the original data table, generate corresponding test data according to different test types and data types, and store the generated test data in the basic test data table of the database; generate corresponding data for the test data according to the steps of generating basic test data; exclude conditional data from the generated test data, filter out the conditional data of the test data and the conditional data of the corresponding data, generate test data for the conditions of the test data and test data for the conditions of the corresponding data, prepare the default data table, connect according to the system table name and field name, form complete data, and output to the result database According to the table; according to the level, obtain the data of the same level in the basic test data table, splice it with the result data in the result data table, judge whether the spliced ​​data triggers the condition, if not, splice it with the default data again, and then perform logical "or" and "and" processing, if yes, directly perform logical "or" and "and" processing, delete the lower layer result data after processing, and perform loop processing here, the level is from 1 to the highest level, each time the result data of the previous level is generated, delete the result data of the next level, until the highest level data is generated, and retain the result data of the maximum level; sort and separate the result data, generate and execute SQL statements, and insert them into the database to complete data production. The present invention also provides a system and application for implementing the above method.

[0053] The present invention provides a method for automatically generating test data, the method comprising the following steps:

[0054] Step 1: Get data according to the template, such as Figure 2 As shown: clear the data in the original data table, read the file list, read the file content, convert the Chinese field names in some fields in the file data into corresponding English field names, convert the Chinese content of some fields into English content, and capitalize the English content of some fields, adjust the data content and store it in the original data table of the database;

[0055] Step 2: Generate basic test data according to the test method in the data, such as Figure 3 As shown: clear the data in the basic test data table, deduplicate the data in the original data table, generate corresponding test data according to different test methods and data types, and then classify and process the data by field type, store the generated test data into the basic test data table of the database according to the field level in the original data table of the database, and set the field level;

[0056] Step 3: Generate the corresponding data of the test data, such as Figure 4As shown: According to the steps of generating basic test data in step 2, the positive corresponding data of the test data is generated, and the field level is the original test table level * 2;

[0057] Step 4: Generate conditional data for test data and conditional data for corresponding data, such as Figure 5 As shown, the generation logic of the conditional data of the test data is the same as step 2, the generation logic of the positive conditional data of the corresponding data is the same as step 3, and the field level is the original test table level * 2 + 1;

[0058] Step 5: Generate complete data, such as Figure 6 As shown: exclude conditional data from the generated test data, adjust and obtain the required content, prepare the default data table, connect according to the system table name and field name, form complete data, and output it to the result data table;

[0059] Step 6: Get the data of the same level in the basic test data table according to the level, and splice it with the result data, such as Figure 7 As shown, it is determined whether the spliced ​​data triggers the condition. If it is triggered, logical processing is directly performed to generate new result data and output it to the result data table. If it is not triggered, it is spliced ​​with the default data, and then logical processing is performed to generate new result data and output it to the result data table. At the same time, the lower layer result data is deleted, and the processing is repeated in this way until all levels are processed.

[0060] Step 7: Process the final results: sort and separate the result data, generate SQL statements and execute them, and finally insert them into the database to complete the production of the test data. Figure 8 shown.

[0061] Specifically,

[0062] In step one,

[0063] 1. Clear the data in the original data table, mainly for repeated execution. The data in this table may be left over from the last test, so clear the data in this table first;

[0064] 2. Read the file list. This step mainly supports the simultaneous import of multiple files, obtains the number of specific files to be imported, and can filter the imported file names to obtain the files that need to be imported;

[0065] 3. Read the contents of the file and store them in the original data table of the database for subsequent calculations;

[0066] 4. For data content conversion, in order to facilitate testers to make data, some validation rules or table names are required to be filled in Chinese by testers, but the program needs to avoid using Chinese as much as possible and convert Chinese into corresponding English content (including field names, specific content, etc.);

[0067] 5. For scenarios where some table names and field names in the data are in English, in order to prevent testers from filling in lowercase and uppercase when filling in, the program unifies the uppercase and lowercase letters and changes all the fields involved in the table to uppercase letters;

[0068] 6. After completing the above tasks, store the data in the original data table to make the data persistent;

[0069] 7. Some of the original data tables need to be adjusted through SQL, mainly for data with backslashes. In order to prevent it from becoming an escape character, add another backslash to the backslash to ensure that the backslash can be correctly recognized.

[0070] The template data format and description are as follows

[0071]

[0072]

[0073]

[0074] If a check has multiple conditions, multiple data items need to be maintained and represented by the condition data, 1 represents the first condition, 2 represents the second condition, and so on.

[0075] In step 2,

[0076] 1. Clear the basic test data table data. The first step is also used to initialize the data and clear the previous basic test data table data;

[0077] 2. Get the original data table data;

[0078] 3. Since the data in the original data table may have multiple conditions, it is necessary to deduplicate the result data of the original data table. For example, if a field in a table is associated multiple times, assume that: when the F field of the T table is equal to the value X, and when the E field of the T table is equal to the value Y as a condition, the G field of the T table cannot be equal to Z as a check. According to the logic of step 1, there will be two data in the G field of the T table with the same test field in the original data table, but different condition fields. At this time, deduplication operation is required;

[0079] 4. Classify the test type according to the original data table, and distinguish whether the test type is a non-relational test type (comparison type) or a relational test type. The main difference between the two is whether it is a dynamic comparison or a fixed value comparison. Relational verification is a dynamic value comparison, and vice versa, it is a fixed value comparison;

[0080] 5. According to different test methods, the default test values ​​in the corresponding test methods are obtained through the test method range table; there is a test method range table, which mainly presets a series of default test data and test results according to the test type. The corresponding default test values ​​and test results are obtained by associating the test methods in the test condition table with the test method table;

[0081] 6. Separate according to field type, mainly numeric type, date type and character type. Different test data will be produced due to different types of data. For example, if the date type is greater than, it is greater than a date. If the numeric type is greater than, it may increase by 0.01 (depending on the precision of the numeric type). Different test data types will have different specific test values, so they need to be separated.

[0082] 7. According to the test type, perform operations on specific data. For comparison filtering, if there are multiple test data, they must be separated by commas. At this time, the program will divide the test data into two, and the rest will be produced according to normal boundary values, code values, lengths, etc. For numerical boundary values, they are automatically calculated according to the accuracy of the data. If it is a date type, one day will be added or subtracted, and no operation will be performed for string types; for length, if it is a numeric type or a date type, no operation will be performed by default. For character types, Chinese characters need special treatment here. If GBK is involved, it will be treated as 2 bits, if it is UTF-8, it will be 3 bits, and if it is nothing, it will be 1 bit, and then increase or decrease according to the boundary value;

[0083] 8. After the data value is prepared, the test result is generated according to the verification conditions. If the condition is equal, the default test result in the test method range is used as the result. If the condition is not equal, it needs to be negated. For other test conditions such as greater than and less than, the actual test result is judged based on the actual test data and conditions.

[0084] 9. For data with relational verification method, the test data field types are: numeric and date test data, and the verification conditions are generally divided into greater than, equal to, less than and not equal to. For test data with character test data field types, the verification conditions are generally divided into equal to and not equal to. For the verification conditions of equal to and not equal to, if the default data in the test data has a value, then this value is taken as the actual data, otherwise the default data in the test method range table is used as the actual data. For the condition of not equal to, a non-default value data is randomly generated, and the actual result is generated according to the actual verification condition. For the verification conditions of greater than and less than, the actual data is generated according to the logic of the previous boundary value test of numeric and date types, and the actual result is generated according to the actual verification condition.

[0085] 10. Finally, all the generated real test data, according to the previously set test method, test data and test results, including forward results and reverse results, are stored in the basic test data table of the database for later automatic verification. And the level of the field is set to 1.

[0086] Step 3: Generate corresponding data for test data

[0087] Note: Some field validations are not simply testing a fixed value, such as equal to XX or not empty, but a dynamic value, another field in the current table, such as the effective date must be greater than the cancellation date, or related fields in other tables; in this case, you need to create the value of this type of corresponding data field;

[0088] The overall steps are basically the same as step 2. The main difference is that the verification type only includes relational verification, the data of the corresponding field only includes positive data and no longer includes reverse data, the level is no longer 1 but the sequence number based on the current condition * 2, and the rest of the detailed steps are shown in step 2.

[0089] Step 4: Generate conditional data for test data and conditional data for corresponding data

[0090] Note: When generating test data, some fields need to be verified based on the specific values ​​of other fields. For example, if the ID type is filled in as ID card, the ID number must be 18 digits. In this case, the ID number is the field that needs to be verified, and the ID type is the conditional field. Some conditions may be more complex and may depend on a field in this data or other data; this step is to generate such data:

[0091] 1. Process the conditional data of the test data and the conditional data of the corresponding data separately according to the original data table;

[0092] 2. For the conditional data of the test data, the processing steps are basically the same as step 2, and the main difference is the verification condition. Here, the verification condition is judged based on whether there is corresponding table data. If there is, it is a relational verification, and if not, it is a comparative verification. Then, the corresponding data is generated according to the verification type;

[0093] 3. For the conditional data of the corresponding data, the processing steps are basically the same as step 3. The default is relational verification, which is also a positive result, without a reverse result;

[0094] 4. The hierarchical relationship here is based on the sequence number of the current condition*2+1.

[0095] The levels in steps 2, 3, and 4 above have clear definitions. The test data is always 1, the corresponding data is always an even number, and the conditional data is always an odd number greater than 2. The level definition here is mainly used to ensure that when generating complete data, if one test data, the test table and the condition table are the same, multiple complete data will not be generated.

[0096] Step 5: Generate complete data

[0097] Note: The previous step is to generate the corresponding test data. Because the entire data is not only test data but also some non-test data, the entire data must be fully matched:

[0098] 1. Get complete test data first;

[0099] 2. Exclude data whose level is not 1;

[0100] 3. Adjust the content and take out the required fields;

[0101] 4. Get the default data table (this table needs to be prepared in advance. Each row of data in it contains the system's test table name, test fields and default values. When these default values ​​form a complete data, no validation will be triggered). Connect according to the system name, the system's table name and the field name in the system's table name to form a complete data. Then, update the default value of the default data table according to the actual value of the basic test data table.

[0102] 5. Finally, a complete data is output to the result table.

[0103] 6. At the same time, the basic test data table will be searched to find the maximum level for the recycling of step six.

[0104] Step 6:

[0105] Note: This step is mainly used to splice conditional data

[0106] 1. For data, first obtain the basic test data table according to the actual level;

[0107] 2. Then splice it with the result data;

[0108] 3. Check whether there is result data: If there is result data, update the default value of the default data table according to the actual value of the basic test data table; and update the positive and negative results of the result data according to the actual positive and negative results and logic (and and or) of the result table and the basic table. For the specific logic, see Table 4; generate the result data of the new result data table with the result data in the final result data table and the current actual level;

[0109] 4. If the result data does not exist, directly add a default data to ensure the data is complete, and assign the current level to the result data table; the specific logic is consistent with step 5;

[0110] 5. Delete the result data in the lower layer.

[0111] In addition, step six also performs a loop process:

[0112] 1. The default level starts at 1;

[0113] 2. The largest level in the test data is used as the maximum level;

[0114] 3. Execute step 6 for each loop level +1;

[0115] 4. Until all levels are processed.

[0116] Step 7: Process the final result

[0117] Description: Mainly to merge the final data and insert it into the database

[0118] 1. Sort the result data in the result data table;

[0119] 2. Separate the fields and specific values ​​in the result data of the result data table, which contains the final positive and negative results, that is, the expected results of the test, mainly used for later data verification;

[0120] 3. Concatenate the specific values ​​and fields into corresponding SQL statements, and execute the SQL statements into the corresponding library to generate the data to be tested, and finally complete the production of the entire data to be tested; the data to be tested is used as test data for software testing.

[0121] In the present invention, the automatic production of test data is divided into three aspects:

[0122] 1. Test Method

[0123] The data testing method is generally based on the data verification range, which includes non-empty, length, format, association, code value, etc.

[0124] Table 1 Data verification range table content description

[0125]

[0126]

[0127] In step 2,

[0128] First, it is necessary to divide according to the verification type, determine the scope of different test methods for different verification types, and form a preliminary default test data.

[0129] There will be a test method range table here. In this test method range table, it is composed of the test method and the test range. For example, the required input test will test four situations, namely empty, Chinese, English, and numbers.

[0130] At this time, one required test data item will become four test data items, and the value of the test data will be updated to the value of the test range in the test method range table.

[0131] The test method range table is as follows Table 2:

[0132] Table 2 Test method scope table specific data

[0133]

[0134]

[0135] Secondly: classify the data by field type.

[0136] Field types are mainly divided into three categories, namely character type, numeric type, and date type. There are different methods for different field types. For example, the length verification method is not applicable to the date type and will be eliminated. For the boundary value verification method, the character type is not applicable and will be eliminated. For the format verification method, neither the date type nor the numeric type is applicable. These inapplicable situations will be specially handled.

[0137] Then, determine the specific test method based on the verification scope and adjust the test data.

[0138] Take the mandatory input test method as an example: fill in the corresponding data according to the value of the test data and the length of the characters in the original basic test data table. If the character length is 8, 8 Chinese characters, 8 English characters or 8 numeric characters will be filled in. If it is a boundary value test, for date fields, the previous day and the next day will be taken according to the set default date. For numeric fields, the value of the corresponding precision will be added or subtracted according to the precision.

[0139] Finally, basic verification data is generated, and the basic verification data includes forward data and reverse data. Finally, the data in the test result table will be obtained.

[0140] Positive data: correct data, does not trigger data verification;

[0141] Reverse data: Incorrect or problematic data will trigger data verification;

[0142] For example: If the verification method of a field is mandatory verification, then any value filled in is positive data, and no value filled in is negative data.

[0143] 2. The default data in step 5 is the default data for test data.

[0144] First, before testing the data, set the default values ​​of all fields in the data and ensure that the default values ​​of all fields do not trigger any other checks to verify the correctness of the checks.

[0145] When creating data, for example, if a piece of data contains 20 fields, you should fill in all the fillable fields as much as possible and ensure that the filled data is positive data, that is, it will not trigger any verification errors. Next, for the specific field that needs to be tested, replace the value of the field with the corresponding test value. This ensures that each verification is only performed for a specific verification type.

[0146] Take the mandatory item verification as an example:

[0147] A piece of data has 5 fields, and if you want to test only one field's mandatory items, the following data will be generated according to the test range in the test method range table, as shown in Table 3:

[0148] Table 3 Test results

[0149] Default Field 1 Default Field 2 Default field 3 Default field 4 Required fields Default 1 Default 2 Default 3 Default 4 middle Default 1 Default 2 Default 3 Default 4 Eng Default 1 Default 2 Default 3 Default 4 1 Default 1 Default 2 Default 3 Default 4

[0150] Secondly,

[0151] Test data is divided into tested data and corresponding data, and each type of data has specific preconditions. Preconditions mean that after some fields are filled in, other fields have specific requirements. For example, if "ID card" is selected in field A, field B must be filled in with 18 digits. If field A is "Passport", field B has no special requirements. In this case, the value of field A is "ID card", which is the precondition for field B verification.

[0152] To meet these prerequisites, four types of data need to be set:

[0153] Test data: the data that is mainly verified.

[0154] Conditional data of test data: preconditions for test data.

[0155] Corresponding data: additional data related to the test data.

[0156] Conditional data of corresponding data: preconditions for associated data.

[0157] If there is no need for associated data, the last two types of data can be omitted.

[0158] Finally, the data that has an impact on the corresponding test field is generated, and then the default value is assigned to the non-test data according to the default value of the data in the default data.

[0159] 3. Test logic

[0160] In the corresponding data test, the test data generation method for multi-condition situations covers a comprehensive strategy. This method decomposes the test conditions into two parts: "conditions" and "results". For multi-condition situations, the test data generation process is handled in layers, with each layer corresponding to a specific condition, and each condition is gradually integrated through cycles from the basic stage to the advanced stage. In each layer, higher-level test data is generated based on the interactions between data and the logical relationships between conditions.

[0161] During the data merging process, a screening mechanism is adopted to remove irrelevant test data to ensure that only valid data of the corresponding level is retained in each iteration. After completing the iteration of all levels, these high-level data are aggregated to form the final test data set.

[0162] This method effectively realizes the automatic generation of test data under complex correlation relationships, ensuring the comprehensiveness and automation level of the test. By combining different conditions, this method can generate more comprehensive, reasonable and relevant test data, significantly improving test coverage and accuracy.

[0163] In the process of processing verification involving multi-condition related data, the verification formula is divided into two parts: condition and result. The condition part usually contains multiple factors, while the result part generally has only one factor. Regardless of whether the condition part is single or multiple, the final actual result is the union result of the final result of the result factor and the final result of the condition factor. In order to effectively manage and generate test data, a hierarchical method is adopted to set different levels for each condition.

[0164] In this layered strategy, each time a condition is added, a new layer is introduced. Starting from the lowest first layer, it is processed gradually upward to higher layers through a recursive loop. At each layer, the combination product between data and the logical relationship between conditions are used to construct higher-level test data. During the data merging process, invalid or irrelevant test data is eliminated through a screening mechanism to ensure that only valid data corresponding to the current highest layer is retained in each cycle.

[0165] When all levels of data are processed, the high-level data is aggregated to generate the final test data set. This automated and layered approach not only ensures that test data generation is comprehensive and efficient, but also significantly improves the coverage and accuracy of the test process.

[0166] The logic of splicing is shown in Table 4 below:

[0167] Table 4 Splicing logic table

[0168]

[0169] There are several special treatments for splicing logic:

[0170] Data 1 and Data 2 are in different fields of the same table.

[0171] 1. When the data on both sides (data 1, data 2) are positive and the logic is a AND relationship, the data is concatenated and then removed;

[0172] 2. When the data on both sides (data 1, data 2) are reversed and the logic is an OR relationship, the data is removed;

[0173] 3. For the test data, if the conditional data needs to be associated with the outside, it is necessary to add abnormal data, and use the positive direction as the result of the spliced ​​data;

[0174] 4. For the case where the test data has no results (corresponding data), remove the case where the final result is positive data;

[0175] 5. For test data with results (test data), remove the case where the final result is reverse data

[0176] The following is a logical example

[0177] Fig. 9 The following is a schematic diagram of the test scenario of the following embodiments.

[0178] Example 1

[0179] like Fig.10 As shown: The institution name field in the institution information table cannot be empty

[0180] 1 When making data, fill in the table name: organization information table, field: organization name: test method: non-empty test;

[0181] 2. When processing a single data, there is no need to splice logic. According to the forward and reverse settings of the non-empty test in the test method range table. When generating test result data, combine the test result table data in the test method range table and the test conditions. If the test result (direction) is P, the check will not be triggered; if it is N, the check will be triggered.

[0182] Example 2

[0183] like Fig.11 As shown, the requirement has been increased. When the institution name is not empty, the institution number cannot be empty.

[0184] Now the conditional data is the organization name, and the test data is the organization number;

[0185] In the conditional data, the corresponding relevant results and methods are obtained through step 4;

[0186] Test data, related results and directions obtained through corresponding step 2;

[0187] When the conditional data and test data are merged, according to the above merging logic;

[0188] First, perform the Cartesian product of the data on both sides. Here, by default, the condition and test data are in a union relationship.

[0189] The two pieces of data generated 4 pieces of data respectively;

[0190] Then, according to the logical screening principle: if it is a union relationship and all are in the direction of P, the data will be eliminated, and finally three numbers will be obtained.

[0191] Example 3

[0192] like Fig.12 As shown, the demand increases to:

[0193] The conditional data is: the institution number in the public account information table needs to be the institution number in the institution information table;

[0194] Test data means that the institution type must be filled in the public account information form;

[0195] Generate the test data in step 2 according to step 2;

[0196] According to step 4, conditional data: Generate the public institution information table;

[0197] According to step 3, generate the conditional data: organization information table:

[0198] First, the data of the same common table are merged by Cartesian product. If the logic is union, the data with two directions of P are eliminated. Then, for the data of the corresponding table, the data with direction of P is eliminated by default. According to the logic, if the corresponding table is not a test table, the P data is eliminated, if it is, the N data is eliminated.

[0199] Finally, the public information table is generated with four data and the institutional information table has one data.

[0200] The above is a demonstration of all examples of this test data.

[0201] The protection content of the present invention is not limited to the above embodiments. Without departing from the spirit and scope of the present invention, changes and advantages that can be thought of by those skilled in the art are included in the present invention and are protected by the attached claims.

Claims

1. A method for automatically generating test data, characterized in that: The method flexibly generates test data that meets the requirements according to specific test requirements and scenarios, thereby supporting comprehensive test coverage and accurate test analysis; the method comprises the following steps: Step 1: Generate original data according to the template: clear the data in the original data table, read the file list, read the file content, convert the Chinese field names of some fields in the file data into corresponding English field names, convert the Chinese content of some fields into English content, and capitalize the English content of some fields, adjust the data content and store it in the original data table of the database; Step 2: Generate basic test data according to the test method in the data: clear the data in the basic test data table, deduplicate the data in the original data table, generate corresponding test data according to different test methods and data types, and then classify and process the data by field type, and store the generated test data in the basic test data table of the database according to the field hierarchy in the original data table of the database; Step 3: Generate corresponding data of test data: Generate positive corresponding data of test data; Step 4: Generate conditional data of test data and conditional data of corresponding data: Generate conditional data of test data and positive conditional data of corresponding data; Step 5: Generate complete data: exclude conditional data from the generated test data, adjust and obtain the required content, prepare the default data table, connect according to the system table name and field name, form complete data, and output it to the result data table; Step 6: Splice the conditional data: obtain the basic test data table according to the level, splice it with the result data in the result data table, determine whether the spliced ​​data triggers the condition, process it according to the determination result, delete the lower level result data after processing, and perform loop processing until all levels are processed; Step 7: Process the final results: sort and separate the result data and fields, generate and execute SQL statements, and insert them into the database to complete data production.

2. The method according to claim 1, characterized in that In step 1, the data consistency in the test data generation process is ensured by clearing the data in the original data table; the file list reading supports reading one or more imported files at the same time, and stores the content in the original data table of the database after reading the file; and / or, Convert the data including test methods and verification conditions from Chinese to English, and capitalize the verification table, verification field, verification condition table, verification condition field, verification correspondence table, verification corresponding field, verification correspondence table condition table, and verification correspondence table condition field; For data containing backslashes, add another backslash symbol so that the backslash can be understood correctly.

3. The method according to claim 1, characterized in that In step 2, the data in the basic test data table is cleared to initialize the data, ensuring that the previous data is cleared, and then the data to be tested is obtained from the original data table; the result data of each field is ensured to be unique by deduplicating the data; and / or, The data is classified according to the test types in the original data table: relational and other test types; the test method range table is used to obtain the default test value according to the determined test type; the data is subdivided according to the field types of numeric, date, and character; the test data of the basic test data table is generated according to the test type and field type, the level of the field is set to 1 and the results are saved in the basic test table.

4. The method according to claim 1, characterized in that In step 3, the test method of the corresponding data of the test data is limited to relational, and the relational positive test data is generated according to the test method and the test data; the field level of the corresponding data is set to obtain the level of the original test table according to the basic test data table*2, and the result is saved in the basic test data table; and / or, In step 4, the forward data and reverse data in the conditional data in the original data table and the corresponding data in the original data table are opposite to the results of the forward data and reverse data in step 2; the field level of the conditional data is set to obtain the level of the original data table based on the basic test data table*2+1, and the result is saved in the basic test data table.

5. The method according to claim 1, characterized in that In step five, after generating the test data of the corresponding basic test data table, further process the non-test data to complete the overall data matching: clear the previous result data table data, obtain the completed basic test data table data, and exclude the data used as conditions; adjust the data content and extract the required fields; prepare a default data table, connect it according to the system table name and field name to form a complete data record, and replace the data to be tested with the test data; the complete data formed will be output to the result data table, and the maximum number of levels of the basic test data table will be recorded.

6. The method according to claim 1, characterized in that In step six, obtain the basic test data table according to the level and splice it with the result data in the result data table; check the splicing result, if the splicing is successful, it means that the result data table already has data, then directly obtain it, otherwise splice it with the default data table to ensure data integrity; determine whether it triggers the condition based on the newly added data, and make a judgment based on the logical conditions of "and" or "or"; process the levels through a loop structure, starting from level 1, each time the loop increases the level by 1, deleting the bottom level and generating the upper level, until all levels are processed, and finally only retaining the result data of the maximum level.

7. The method according to claim 1, characterized in that In step seven, the result data in the result data table are sorted, and then the fields and specific values ​​in the result data in the result data table are separated while retaining the expected results of the test; the specific values ​​and fields are spliced ​​into corresponding SQL statements, and these SQL statements are executed to insert the data to be tested into the corresponding final database, completing the entire work of producing the data to be tested.

8. A test data automatic generation system, characterized in that: The system comprises: a memory and a processor; a computer program is stored in the memory, and when the computer program is executed by the processor, the method according to claims 1 to 7 is implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to claims 1 to 7 is implemented.

10. Application of the method according to claims 1 to 7, the generation system according to claim 8, or the computer-readable storage medium according to claim 9 in quality verification of data submitted in accordance with regulatory requirements.