Test data generation method and apparatus, device, and storage medium

By generating test data through a combination of a test data rule table and a custom rule database table, the problem of insufficient test data in existing technologies is solved, and rich test data that conforms to real-world patterns is generated.

CN115587027BActive Publication Date: 2026-03-24CHINA CONSTRUCTION BANK +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-27
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

Existing test data generation methods cannot generate sufficient test data that conforms to real-world patterns, resulting in inaccurate testing.

Method used

Test data rule tables are generated by combining the relationships between physical primary keys and physical foreign keys of multiple database tables. Data source information and generation rules are customized. Test data tables are created based on field types and test data is generated by combining the relationships between multiple database tables.

Benefits of technology

The generated test data is rich in dimensions, with complete relationships between data points, conforms to real-world patterns, and improves the authenticity and diversity of the test data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115587027B_ABST
    Figure CN115587027B_ABST
Patent Text Reader

Abstract

The application discloses a test data generation method and device, equipment and a storage medium. The test data generation method comprises the following steps: obtaining a plurality of target record contents from a test data rule table, each target record content comprising a field type, data source information, test data generation rule information corresponding to the data source, and a record number; for each target record content, generating a test data table based on the data source information, the test data generation rule information, the record number, and a first table generated based on the field type; and finally, combining a plurality of test data tables based on the association relationship between the physical primary keys and the physical foreign keys of the plurality of database tables to obtain test data. According to the embodiment of the application, the test data is generated, the test data is rich in dimensions, the association relationship between the data is complete, and conforms to the real law.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of computers, and in particular to a test data generation method and device, equipment, storage medium and computer program product. BACKGROUND

[0002] Generally, a data class software system needs to be tested for multiple rounds before being put into production, and test data is the key to the testing process. However, the existing test data is usually insufficient to accurately test, and therefore a large amount of test data needs to be found.

[0003] Many existing systems simulate one or several real data in advance, and then create test data by copying and pasting, etc. The test data created in this way is single. SUMMARY

[0004] The embodiments of the present application provide a test data generation method, device, equipment and computer storage medium, which can visually display the physical relationship between database tables according to the characteristics of bank data, form a test data rule table, generate a test data table according to data source information, test data generation rule information corresponding to the data source and the number of records and a first table created based on the field type, and combine multiple test data tables according to the association relationship between the multiple database tables to generate test data. The test data obtained is rich in dimensions, the association relationship between the data is complete, and the data conforms to the real law.

[0005] In a first aspect, the embodiments of the present application provide a test data generation method, which comprises:

[0006] Obtaining multiple target record contents from a test data rule table, the test data rule table being a rule table generated based on the association relationship between the physical primary keys and the physical foreign keys of multiple database tables, each target record content including a field type, data source information, test data generation rule information corresponding to the data source, and the number of records;

[0007] For each target record content, creating a first table based on the field type, the first table including the field type;

[0008] For each target record content, generating a test data table based on the data source information, the test data generation rule information, the number of records, and the first table generated based on the field type;

[0009] Based on the association relationship between the physical primary keys and the physical foreign keys of the multiple database tables, combining the multiple test data tables to obtain test data.

[0010] In some embodiments, the data source information comprises one of a sequence number of a database, information of obtaining or manually simulating data from a production environment, and equivalent information, and the test data generation rule information comprises at least one of self-increment, distribution, random, random fixed-length unique, and equivalent filling.

[0011] In some embodiments, when the data source information comprises the sequence number of the database and the test data generation rule is self-increment, for each target record content, the test data table is generated based on the data source information, the test data generation rule information, the record number, and a first table generated based on the field type, comprising:

[0012] According to the sequence number of the database, a self-increment sequence number of the record number is obtained from the database table for each target record content;

[0013] Data corresponding to the record number is obtained from the database table corresponding to the self-increment sequence number;

[0014] The self-increment sequence number and the data are inserted into the first table to obtain the test data table.

[0015] In some embodiments, when the data source information comprises the information of obtaining or manually simulating data from the production environment and the test data generation rule is distribution, for each target record content, the test data table is generated based on the data source information, the test data generation rule information, the record number, and a first table generated based on the field type, comprising:

[0016] Data corresponding to the record number is obtained from the database table for each target record content;

[0017] The data is inserted into the first table according to the distribution rule to obtain the test data table.

[0018] In some embodiments, when the data source information comprises the information of obtaining or manually simulating data from the production environment and the test data generation rule is random fixed-length unique, for each target record content, the test data table is generated based on the data source information, the test data generation rule information, the record number, and a first table generated based on the field type, comprising:

[0019] Data corresponding to the record number is obtained from the database table for each target record content;

[0020] A certain segment of characters of the data corresponding to the record number is randomly replaced to generate target test data corresponding to the record number;

[0021] The target test data is inserted into the first table to obtain the test data table.

[0022] In some embodiments, when the data source information includes information of obtaining or manually simulating data from a production environment, and the test data generation rule is random, for each target record content, a test data table is generated based on the data source information, the test data generation rule information, the number of records, and the first table generated based on the field type, including:

[0023] For each target record content, a number of records corresponding to the number of records are obtained from the database table;

[0024] Randomly replace all characters of the number of records corresponding to the number of records to generate target test data corresponding to the number of records;

[0025] Insert the target test data into the first table to obtain the test data table.

[0026] In some embodiments, when the data source information includes equivalence information, and the test data generation rule is equivalence filling, for each target record content, a test data table is generated based on the data source information, the test data generation rule information, the number of records, and the first table generated based on the field type, including:

[0027] For each target record content, a number of records corresponding to the number of records are obtained from the database table;

[0028] Randomly sort the number of records corresponding to the number of records to generate target test data corresponding to the number of records;

[0029] Insert the target test data into the first table to obtain the test data table.

[0030] In some embodiments, when the data source information includes equivalence information, and the test data generation rule is distribution, for each target record content, a test data table is generated based on the data source information, the test data generation rule information, the number of records, and the first table generated based on the field type, including:

[0031] For each target record content, a number of records corresponding to the number of records are obtained from the database table;

[0032] According to the rule of distribution, the data is inserted into the first table to obtain the test data table.

[0033] In some embodiments, when the test data generation rule is distribution, the distribution can include one of Poisson distribution, average distribution, normal distribution, left skewed distribution, right skewed distribution, binomial distribution, and multinomial distribution.

[0034] In some embodiments, before obtaining the target record content from the test data rule table, the method further includes:

[0035] obtaining a plurality of database tables, the plurality of database tables comprising at least one of participant information, contract, condition, product, location, classification, business direction, event, and resource item data tables;

[0036] determining a data generation order in the test data rule table based on a correlation between the physical primary keys and the physical foreign keys of the plurality of database tables;

[0037] obtaining data from the corresponding database tables according to the data generation order, and generating the test data rule table.

[0038] In some embodiments, the correlation between the physical primary keys and the physical foreign keys of the plurality of database tables comprises a user-defined correlation between the physical primary keys and the physical foreign keys of the plurality of database tables.

[0039] In some embodiments, the data source information, the test data generation rule information corresponding to the data source, and the record number comprise:

[0040] user-defined data source information, test data generation rule information corresponding to the data source, and a record number.

[0041] In some embodiments, after the test data is generated, the method further comprises deleting the test data table.

[0042] In a second aspect, an embodiment of the present application provides a test data generation device, the device comprising:

[0043] an obtaining module configured to obtain a plurality of target record contents from a test data rule table, the test data rule table being a rule table generated based on a correlation between physical primary keys and physical foreign keys of a plurality of database tables, each target record content comprising a field type, data source information, test data generation rule information corresponding to the data source, and a record number;

[0044] a generating module configured to, for each target record content, create a first table based on the field type, the first table comprising the field type;

[0045] the generating module is further configured to, for each target record content, generate a test data table based on the data source information, the test data generation rule information, the record number, and the first table generated based on the field type, to obtain the test data table;

[0046] the generating module is further configured to combine a plurality of test data tables based on the correlation between the physical primary keys and the physical foreign keys of the plurality of database tables to obtain test data.

[0047] In some embodiments, the data source information comprises one of a sequence number of the database, information of obtaining or manually simulating data from a production environment, and equivalent information, and the test data generation rule information comprises at least one of self-increment, distribution, random, random fixed-length unique, and equivalent filling.

[0048] In some embodiments, the generation module is configured to, when the data source information comprises a sequence number of the database and the test data generation rule is self-increment, generate, for each target record content, a test data table based on the data source information, the test data generation rule information, the number of records, and a first table generated based on the field type, comprising:

[0049] obtaining, for each target record content, a self-increment sequence number of the number of records from the database table according to the sequence number of the database;

[0050] obtaining, for each target record content, a self-increment sequence number of the number of records from the database table according to the sequence number of the database;

[0051] obtaining, for each target record content, a self-increment sequence number of the number of records from the database table according to the sequence number of the database;

[0052] In some embodiments, the generation module is configured to, when the data source information comprises information of obtaining or manually simulating data from a production environment and the test data generation rule is distribution, generate, for each target record content, a test data table based on the data source information, the test data generation rule information, the number of records, and a first table generated based on the field type, comprising:

[0053] obtaining, for each target record content, a self-increment sequence number of the number of records from the database table according to the sequence number of the database;

[0054] obtaining, for each target record content, a self-increment sequence number of the number of records from the database table according to the sequence number of the database;

[0055] In some embodiments, the generation module is configured to, when the data source information comprises information of obtaining or manually simulating data from a production environment and the test data generation rule is random fixed-length unique, generate, for each target record content, a test data table based on the data source information, the test data generation rule information, the number of records, and a first table generated based on the field type, comprising:

[0056] obtaining, for each target record content, a self-increment sequence number of the number of records from the database table according to the sequence number of the database;

[0057] obtaining, for each target record content, a self-increment sequence number of the number of records from the database table according to the sequence number of the database;

[0058] obtaining, for each target record content, a self-increment sequence number of the number of records from the database table according to the sequence number of the database;

[0059] In some embodiments, the generating module is configured to, when the data source information comprises information of obtaining data from a production environment or manually simulating data, and the test data generation rule is random, generate, for each target record content, a test data table based on the data source information, the test data generation rule information, the record number, and the first table based on the field type, including:

[0060] obtaining, for each target record content, a number of data corresponding to the record number from the database table;

[0061] randomly replacing all characters of the number of data corresponding to the record number to generate target test data corresponding to the number of record number;

[0062] inserting the target test data into the first table to obtain the test data table.

[0063] In some embodiments, the generating module is configured to, when the data source information comprises equivalence information, and the test data generation rule is equivalence filling, generate, for each target record content, a test data table based on the data source information, the test data generation rule information, the record number, and the first table based on the field type, including:

[0064] obtaining, for each target record content, a number of data corresponding to the record number from the database table;

[0065] randomly sorting the number of data corresponding to the record number to generate target test data corresponding to the number of record number;

[0066] inserting the target test data into the first table to obtain the test data table.

[0067] In some embodiments, the generating module is configured to, when the data source information comprises equivalence information, and the test data generation rule is distribution, generate, for each target record content, a test data table based on the data source information, the test data generation rule information, the record number, and the first table based on the field type, including:

[0068] obtaining, for each target record content, a number of data corresponding to the record number from the database table;

[0069] inserting the data into the first table according to the distribution rule to obtain the test data table.

[0070] In some embodiments, when the test data generation rule is distribution, the distribution can include one of Poisson distribution, average distribution, normal distribution, left-skewed distribution, right-skewed distribution, binomial distribution, and multinomial distribution.

[0071] In some embodiments, the obtaining module is configured to customize the data source information, the test data generation rule information corresponding to the data source, and the record number.

[0072] In some embodiments, the apparatus further comprises:

[0073] a database table obtaining module, before obtaining target record contents from a test data rule table, obtaining a plurality of database tables, the plurality of database tables including at least one of participant information, contracts, conditions, products, locations, categories, business directions, events, and resource item data table libraries,

[0074] a test data rule table generating module, based on an association relationship between a plurality of library table physical primary keys and physical foreign keys, determining a data generation order in the test data rule table, obtaining data from corresponding database tables according to the generation order, and generating the test data rule table.

[0075] In some embodiments, the test data rule table generating module is used for an association relationship between a plurality of library table physical primary keys and physical foreign keys customized by a user.

[0076] In some embodiments, the apparatus further comprises:

[0077] a deletion module, configured to delete the test data table after the test data is generated.

[0078] In a third aspect, an electronic device is provided, and the electronic device includes a processor and a memory storing computer program instructions.

[0079] The processor, when executing the computer program instructions, implements the steps of the test data generation method in any one of the embodiments of the first aspect.

[0080] In a fourth aspect, a computer readable storage medium is provided, and the computer readable storage medium stores computer program instructions. The computer program instructions, when executed by a processor, implement the steps of the test data generation method in any one of the embodiments of the first aspect.

[0081] In a fifth aspect, a computer program product is provided, and instructions in the computer program product are executed by a processor of an electronic device, so that the electronic device performs the steps of the test data generation method in any one of the embodiments of the first aspect.

[0082] The test data generation method, device, medium and product provided by the embodiments of the present application can generate a test data rule table through the association relationship between the physical primary keys and the physical foreign keys of multiple database tables, the user can customize to add the association relationship between the physical primary keys and the physical foreign keys of multiple database tables, and can also customize the data source information in the test data rule table, the test data generation rule information corresponding to the data source and the record number, generate a test data table according to the test data rule table and the first table created based on the field type, and finally, combine multiple test data tables to generate test data according to the association relationship between the multiple database tables. In this way, the generated test data is rich in dimensions, the association relationship between the data is complete, and conforms to the real law. BRIEF DESCRIPTION OF DRAWINGS

[0083] Figure 1 is a flowchart of a test data generation method provided by the embodiments of the present application;

[0084] Figure 2 is a schematic diagram of the association relationship between the physical primary keys and the physical foreign keys of multiple database tables provided by the embodiments of the present application;

[0085] Figure 3 is a first representation provided by the embodiments of the present application;

[0086] Figure 4 is a flowchart of a test data generation method provided by the embodiments of the present application;

[0087] Figure 5 is a flowchart of another test data generation method provided by the embodiments of the present application;

[0088] Figure 6 is a flowchart of another test data generation method provided by the embodiments of the present application;

[0089] Figure 7 is a structural schematic diagram of a test data generation device provided by the embodiments of the present application;

[0090] Figure 8 is a structural schematic diagram of an electronic device provided by the embodiments of the present application. DETAILED DESCRIPTION

[0091] The features and exemplary embodiments of various aspects of the present application will be described in detail below with reference to the drawings. For the purpose of clarity, technical terms may be defined herein before being consistently used throughout the specification. Embodiments of the present application will be described in further detail with reference to the drawings and specific examples. It is to be understood that the specific examples are only intended for explanation and are not intended to limit the present application. The present application can be implemented without some of the specific details, which are well known to those skilled in the art. The following description of the embodiments is merely provided to give a better understanding of the present application by showing examples of the present application.

[0092] It should be noted that the relational terms herein such as first and second and the like are used solely to distinguish one from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element preceded by "comprises... " does not, without more constraints, foreclose the existence of additional identical elements in the process, method, article, or apparatus that comprises the named element.

[0093] The acquisition, storage, use, processing, etc. of data in the technical solutions of the present application comply with relevant provisions of national laws and regulations.

[0094] At the present stage, data type software systems need to be tested for multiple rounds after development is completed and before being put into production online. Test data is the key to the testing link, and the existing test data is usually less and cannot be accurately tested. Therefore, a large amount of test data needs to be found.

[0095] Many existing systems simulate one or several real data in advance, and then manufacture test data through copying, pasting and other means. The test data manufactured by this manufacturing method is single

[0096] To solve the problems in the prior art, the embodiments of the present application provide a test data generation method, device, equipment, medium and product. The test data generation method can be applied to a software testing scene. First, the test data generation method provided by the embodiments of the present application will be introduced.

[0097] Figure 1 is a flowchart of the test data generation method provided by an embodiment of the present application. As shown in Figure 1 the test data generation method can specifically include the following steps:

[0098] S110, obtain a plurality of target record contents from a test data rule table, the test data rule table is a rule table generated based on an association relationship between physical primary keys and physical foreign keys of a plurality of database tables, each target record content includes a field type, data source information, test data generation rule information corresponding to the data source, and a record number;

[0099] S120, for each target record content, create a first table based on the field type, the first table including the field type;

[0100] S130, for each target record content, generate a test data table based on the data source information, the test data generation rule information, the record number, and the first table generated based on the field type;

[0101] S140, combine a plurality of test data tables based on the association relationship between the physical primary keys and the physical foreign keys of the plurality of database tables to obtain test data.

[0102] Thus, by obtaining a plurality of target record contents from a test data rule table, each target record content including a field type, data source information, test data generation rule information corresponding to the data source, and a record number, for each target record content, generating a test data table based on the data source information, the test data generation rule information, the record number, and the first table generated based on the field type, and finally, combining a plurality of test data tables based on the association relationship between the physical primary keys and the physical foreign keys of the plurality of database tables to obtain test data. In this way, since test data is generated for different data sources according to the test data generation rule corresponding to the corresponding data source, and the test data is obtained after the plurality of test data tables are combined based on the association relationship between the physical primary keys and the physical foreign keys of the plurality of database tables, the obtained test data is rich in dimension, the association relationship between the data is complete, and the data conforms to the real law.

[0103] The specific implementation of each step is described below.

[0104] In S110, the test data rule table can include a field type, data source information, test data generation rule information corresponding to the data source, and a record number.

[0105] The test data rule table is generated according to the association relationship between the physical primary keys and the physical foreign keys of the plurality of database tables, and the association relationship between the physical primary keys and the physical foreign keys of the plurality of database tables can also be referred to as a visual blood relationship between tables. The physical primary key is a key value that contains the exact meaning of the database table and is unique, located in the first row of the database table, and the physical foreign key is a connection method that uses a foreign key to associate a field in another database table, that is, the association relationship between data in different database tables.

[0106] In one example, the database tables are taken as an example of a customer table, a contract table and an account table, as shown in FIG. 1, the physical foreign key is a connection between the field types in the customer table and the contract table, and a connection between the field types in the contract table and the account table. Figure 2

[0107] In some embodiments, the data source information can include one of a serial number of a database, information of obtaining or manually simulating data from a production environment, and equivalent information, and the test data generation rule information includes at least one of self-increment, distribution, random, random fixed-length unique, and equivalent filling.

[0108] By corresponding to different data source information, the test data generation rule corresponding to different data sources is formulated, which can avoid the single test data and enrich the test data dimension.

[0109] In some embodiments, the data source information, the test data generation rule information corresponding to the data source, and the record number include:

[0110] The data source information, the test data generation rule information corresponding to the data source, and the record number customized by the user.

[0111] In some embodiments, the data source information, the test data generation rule information corresponding to the data source, and the record number can also be automatically generated based on the customized rules.

[0112] In this way, for some data source information, test data generation rule information corresponding to the data source, and record number in the test data rule table that do not conform to the real law, they can be deleted, added or modified, so that the test data rule table can be more in line with the expected requirements, that is, the test data rule formulated for different source data is more in line with the data itself.

[0113] In S120, a first table is created based on the field type of each record. The field type is included in the first table, that is, the physical primary key of the first table, and the first table includes the physical primary key of the first table and the data corresponding to the physical primary key. Taking the field type Number as an example, details are shown in FIG. 2. Figure 3 , Figure 3 It is only a schematic diagram of the first table.

[0114] Therefore, the first table is created based on the field type of each record, the exact meaning of each first table can be clearly defined based on the field type, and the test data is classified.

[0115] ​In S130, a test data table is generated based on the data source information of each target record content, the test data generation rule information, the record number, and a first table generated based on the field type. For example, when the data source information is information obtained from a production environment or manually simulated data, the test data generation rule information is distribution, and the record number is 50, 50 pieces of information obtained from the production environment or manually simulated data are taken from a database table, and the 50 pieces of data are inserted into the first table according to the distribution rule to obtain a test data table with a data amount of 50.

[0116] By using the data source information and the test data generation rule information, the test data is generated in a corresponding generation mode corresponding to the test data generation rule information, and the number of generated test data is determined according to the record number, so that the quality of the generated test data is improved.

[0117] In S140, a plurality of test data tables are combined according to the association relationship between the plurality of database tables, that is, the data in the plurality of test data tables is redistributed according to the association relationship between the physical primary keys and the physical foreign keys in the plurality of test data tables and the order of the association relationship.

[0118] In this way, based on the test data rule table, the record content is obtained from the test data rule table, the data is obtained from the database based on the field type, the data source information, the test data generation rule information corresponding to the data source, and the record number, and the data is inserted into the first table generated based on the field type, and then the plurality of test data are combined according to the association relationship between the physical primary keys and the physical foreign keys in the database table to obtain test data, so that the generated test data is more realistic, more dimensionally rich, and more in line with the real law.

[0119] For different data source information, test data generation rules corresponding to the data source information, and record numbers, S130 can specifically include steps S1301 to S1316, details of which are described below. Figure 4 .

[0120] In some embodiments, in S130, when the data source information includes a sequence number of a database and the test data generation rule is self-incrementing, S130 includes S1301, S1302, and S1303, and for each target record content, a test data table is generated based on the data source information, the test data generation rule information, the record number, and a first table generated based on the field type, including:

[0121] S1301, for each target record content, a self-incrementing sequence number of a record number is obtained from a database table according to a sequence number of the database;

[0122] S1302, data corresponding to the number of records is obtained from a database table corresponding to the self-incrementing sequence number.

[0123] S1303 inserts the self-incrementing serial number and the data into the first table to obtain a test data table.

[0124] In this way, different test data generation rules can be formulated for different data source information, so that the generated test data is more in line with real rules.

[0125] In some embodiments, in S130, when the data source information includes information of obtaining or manually simulating data from a production environment, and the test data generation rule is distribution, S130 includes S1304 and S1305, for each target record content, generating a test data table based on the data source information, the test data generation rule information, the number of records, and the first table based on the field type, including:

[0126] S1304, for each target record content, obtaining a number of data corresponding to the number of records from a database table;

[0127] S1305, inserting the data into the first table according to the distribution rule to obtain the test data table.

[0128] In this way, by directly obtaining data from the database table and adopting a new arrangement mode, i.e., the distribution rule, the randomness of the test data is improved while ensuring the authenticity of the data.

[0129] In some embodiments, in S130, when the data source information includes information of obtaining or manually simulating data from a production environment, and the test data generation rule is random fixed-length uniqueness, S130 can include S1306, S1307, and S1308, for each target record content, generating a test data table based on the data source information, the test data generation rule information, the number of records, and the first table based on the field type, including:

[0130] S1306, for each target record content, obtaining a number of data corresponding to the number of records from a database table;

[0131] S1307, randomly replacing a certain segment of characters of the data corresponding to the number of records to generate target test data corresponding to the number of records;

[0132] S1308, inserting the target test data into the first table to obtain a test data table.

[0133] In this way, by replacing part of the data in the original database table, test data close to the original data can be obtained, which ensures the authenticity of the test data while making the test data novel.

[0134] In some embodiments, in S130, when the data source information comprises information of obtaining or manually simulating data from a production environment, and the test data generation rule is random, S130 can comprise S1309, S1310, S1311, for each target record content, generating a test data table based on the data source information, the test data generation rule information, the number of records, and the first table based on the field type, comprising:

[0135] S1309, obtaining a number of records corresponding to the number of records from the database table;

[0136] S1310, randomly replacing all characters of the number of records corresponding to the number of records to generate target test data corresponding to the number of records;

[0137] S1311, inserting the target test data into the first table to obtain the test data table.

[0138] In this way, by replacing all the metadata in the database table, the generated test data retains the data format of the original data, but the content is completely different from the original data, which can improve the authenticity of the test data and reduce the repeatability of the test data.

[0139] In some embodiments, in S130, when the data source information comprises equivalence information, and the test data generation rule is equivalence filling, S130 can comprise S1312, S1313, S1314, for each target record content, generating a test data table based on the data source information, the test data generation rule information, the number of records, and the first table based on the field type, comprising:

[0140] S1312, obtaining a number of records corresponding to the number of records from the database table;

[0141] S1313, randomly sorting the number of records corresponding to the number of records to generate target test data corresponding to the number of records;

[0142] S1314, inserting the target test data into the first table to obtain the test data table.

[0143] In this way, by randomly sorting the original data in the database table, the arrangement and combination order of the data can be changed, so that the test data has variability and conforms to the rules of real data.

[0144] In some embodiments, in S130, when the data source information comprises equivalence information, and the test data generation rule is distribution, S130 can comprise S1315, S1316, for each target record content, generating a test data table based on the data source information, the test data generation rule information, the number of records, and the first table based on the field type, comprising:

[0145] S1315, for each target record content, obtaining a number of data corresponding to the number of records from the database table;

[0146] S1316, inserting the data into the first table according to the distribution rule to obtain a test data table.

[0147] In this way, by redistributing the original data in the database table, the relative data density of the original data can be changed, and the generated test data is more in line with the real law.

[0148] In some embodiments, in S130, when the test data generation rule is distribution, the distribution can include one of Poisson distribution, average distribution, normal distribution, left skewed distribution, right skewed distribution, binomial distribution and multinomial distribution.

[0149] In this way, by specifying the distribution rule, the generated test data can be closer to reality and have higher authenticity.

[0150] In addition, in order to make the matching degree of the data source information in the test data rule table, the test data generation rule corresponding to the data source information and the data higher, the present application provides another test data generation method, as shown in Figure 5 Before S110, the method further includes S100.

[0151] S100, obtaining a plurality of database tables, the plurality of database tables including at least one of participant information, contract, condition, product, location, classification, business direction, event, and resource item data table library, determining the data generation order in the test data rule table based on the association relationship between the physical primary keys and the physical foreign keys of the plurality of database tables, and obtaining data from the corresponding database table according to the generation order to generate the test data rule table;

[0152] In S100, the plurality of database tables can include a customer table, a contract table, an account table, a product table, and an account flow table, and the association relationship between the physical primary keys and the physical foreign keys of the organization table library can be "customer-contract-account-product-flow", which is not limited herein.

[0153] In this way, each time the test data to be generated is different, the corresponding test data rule table is also different, and when the test data to be generated changes, the corresponding test data rule table also changes, so that the test data rule table is more in line with the requirements, and the test data generated based on the test data rule table is more real and in line with the real law.

[0154] In some embodiments, the association relationship between the physical primary keys and the physical foreign keys of the plurality of database tables includes a plurality of association relationships between the physical primary keys and the physical foreign keys of the plurality of database tables customized by a user.

[0155] In this way, for database tables where the relationship between physical primary keys and physical foreign keys does not conform to real-world patterns, the relationship between physical primary keys and physical foreign keys can be customized, added, deleted, or modified. This makes the test data rule table more in line with actual requirements, and the test data generated based on the test data rule table has stronger regularity and greater realism.

[0156] In addition, to make the generated test data cleaner, this application also provides another method for generating test data, which involves deleting the previously generated test data table after generating the test data.

[0157] In some embodiments, such as Figure 6 As shown, after S140, the method may also include S150.

[0158] S150, Delete the test data table.

[0159] In S150, the deleted test data table is the test data table generated in S130 for each target record, based on the data source information, test data generation rule information, number of records, and the first table generated based on field types.

[0160] In this way, deleting the test data table after generating the test data ensures that the generated test data is clean and tidy, while avoiding wasting storage space and improving the utilization rate of storage space.

[0161] Therefore, a test data rule table is generated by leveraging the relationships between physical primary keys and foreign keys in multiple database tables. Users can customize the relationships between physical primary keys and foreign keys in multiple database tables, as well as define the data source information, corresponding test data generation rules, and record count in the test data rule table. A test data table is generated based on the test data rule table and a first table created based on field types. The test data tables are then combined based on the relationships between the multiple database tables to generate test data. Finally, the test data table is deleted. This method produces clean and concise test data with rich data dimensions, complete relationships between data points, and conformity to real-world patterns. It also avoids wasting storage space and improves storage space utilization.

[0162] Based on the same inventive concept, this application also provides a device for generating test data. (Specifically combined with...) Figure 7 Please provide a detailed explanation.

[0163] Figure 7 This is a schematic diagram of the structure of a test data generation device provided in one embodiment of this application.

[0164] like Figure 7 As shown, the feature extraction device 700 for the official document text may include:

[0165] an obtaining module, configured to obtain a plurality of target record contents from a test data rule table, the test data rule table being a rule table generated based on an association relationship between physical primary keys and physical foreign keys of a plurality of database tables, and each target record content including a field type, data source information, test data generation rule information corresponding to the data source, and a record number;

[0166] a generating module, configured to, for each target record content, create a first table based on the field type, the first table including the field type;

[0167] The generating module is further configured to, for each target record content, generate a test data table based on the data source information, the test data generation rule information, the record number, and the first table generated based on the field type, to obtain the test data table.

[0168] The generating module is further configured to combine the plurality of test data tables based on the association relationship between the physical primary keys and the physical foreign keys of the plurality of database tables to obtain test data.

[0169] In some embodiments, the data source information obtained by the obtaining module includes one of a serial number of a database, information of obtaining or manually simulating data from a production environment, and equivalent information, and the test data generation rule information includes at least one of self-increment, distribution, random, random fixed-length uniqueness, and equivalent filling.

[0170] In some embodiments, the generating module is configured to, when the data source information includes the serial number of the database and the test data generation rule is self-increment, generate, for each target record content, the test data table based on the data source information, the test data generation rule information, the record number, and the first table generated based on the field type, including:

[0171] obtaining, for each target record content, a self-increment serial number of the record number from the database table according to the serial number of the database;

[0172] obtaining, from the database table corresponding to the self-increment serial number, data of a number corresponding to the record number;

[0173] inserting the self-increment serial number and the data into the first table to obtain the test data table.

[0174] In some embodiments, the generating module is configured to, when the data source information includes the information of obtaining or manually simulating data from the production environment and the test data generation rule is distribution, generate, for each target record content, the test data table based on the data source information, the test data generation rule information, the record number, and the first table generated based on the field type, including:

[0175] obtaining, for each target record content, data of a number corresponding to the record number from the database table;

[0176] The data is inserted into the first table according to the distribution rule to obtain a test data table.

[0177] In some embodiments, the generating module is configured to, when the data source information comprises information of obtaining data from a production environment or manually simulating data, and the test data generation rule is a random fixed-length unique, generate the test data table based on the data source information, the test data generation rule information, the number of records, and the first table based on the field type for each target record content, including:

[0178] For each target record content, a number of data corresponding to the number of records is obtained from the database table;

[0179] Randomly replace a segment of characters of the number of data corresponding to the number of records to generate target test data corresponding to the number of records;

[0180] The target test data is inserted into the first table to obtain a test data table.

[0181] In some embodiments, the generating module is configured to, when the data source information comprises information of obtaining data from a production environment or manually simulating data, and the test data generation rule is random, generate the test data table based on the data source information, the test data generation rule information, the number of records, and the first table based on the field type for each target record content, including:

[0182] For each target record content, a number of data corresponding to the number of records is obtained from the database table;

[0183] Randomly replace all characters of the number of data corresponding to the number of records to generate target test data corresponding to the number of records;

[0184] The target test data is inserted into the first table to obtain a test data table.

[0185] In some embodiments, the generating module is configured to, when the data source information comprises equivalent information, and the test data generation rule is equivalent filling, generate the test data table based on the data source information, the test data generation rule information, the number of records, and the first table based on the field type for each target record content, including:

[0186] For each target record content, a number of data corresponding to the number of records is obtained from the database table;

[0187] Randomly sort the number of data corresponding to the number of records to generate target test data corresponding to the number of records;

[0188] The target test data is inserted into the first table to obtain a test data table.

[0189] In some embodiments, the generating module is configured to, when the data source information comprises equivalent information, and the test data generation rule is distribution, generate, for each target record content, a test data table based on the data source information, the test data generation rule information, the record number, and the first table generated based on the field type, comprising:

[0190] For each target record content, a number of records corresponding to the record number are obtained from the database table;

[0191] According to the distribution rule, the data is inserted into the first table to obtain the test data table.

[0192] In some embodiments, when the test data generation rule is distribution, the distribution can include one of Poisson distribution, average distribution, normal distribution, left skew distribution, right skew distribution, binomial distribution, and multinomial distribution.

[0193] In some embodiments, the obtaining module is configured to obtain the data source information, the test data generation rule information corresponding to the data source, and the record number.

[0194] In some embodiments, the apparatus further comprises:

[0195] The database table obtaining module obtains a plurality of database tables before obtaining the target record content from the test data rule table, the plurality of database tables comprising at least one of participant information, contracts, conditions, products, locations, categories, business directions, events, and resource item data table libraries,

[0196] The test data rule table generating module determines the data generation order in the test data rule table based on the association relationship between the plurality of library table physical primary keys and physical foreign keys, obtains data from the corresponding database tables according to the generation order, and generates the test data rule table.

[0197] In some embodiments, the test data rule table generating module is configured to customize the association relationship between the plurality of library table physical primary keys and physical foreign keys by the user.

[0198] In some embodiments, the apparatus further comprises:

[0199] The deleting module is configured to delete the test data table after generating the test data.

[0200] Thus, the test data rule table is generated through the association relationship between the physical primary keys and the physical foreign keys of the plurality of database tables, the user can customize to add the association relationship between the physical primary keys and the physical foreign keys of the plurality of database tables, and can also customize the data source information in the test data rule table, the test data generation rule information corresponding to the data source, and the record number, the test data table is generated according to the test data rule table and the first table created based on the field type, the plurality of test data tables are combined to generate test data according to the association relationship between the plurality of database tables, and finally, the test data table is deleted. In this way, since the test data is generated according to the test data generation rule corresponding to the different data sources, and the test data is obtained by combining the plurality of test data tables based on the association relationship between the physical primary keys and the physical foreign keys of the plurality of database tables, and the test data table is deleted after the test data is obtained, the obtained test data is clean and neat, the data dimension is rich, the association relationship between the data is complete, the data conforms to the real law, and at the same time, the storage space is avoided to be wasted, and the utilization rate of the storage space is improved.

[0201] Figure 8 FIG. 1 is a structural schematic diagram of an electronic device provided by an embodiment of the present application.

[0202] The electronic device 800 can include a processor 801 and a memory 802 storing computer program instructions.

[0203] Specifically, the processor 801 can include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present application.

[0204] The memory 802 can include a mass storage for data or instructions. By way of example and not limitation, the memory 802 can include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. Where appropriate, the memory 802 can include removable or non-removable (or fixed) media. The memory 802 can be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, the memory 802 is non-volatile solid-state memory.

[0205] The memory 802 can include read-only memory (ROM), random access memory (RAM), magnetic disk storage mediums, optical storage mediums, flash memory devices, electrical, optical, or other physical / tangible memory storage devices. Thus, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software that, when executed (by one or more processors), is operable to perform the operations described with reference to the methods according to an aspect of the present disclosure. The processor 801 implements functions by reading and executing computer program instructions stored in the memory 802. The processor 801 can include a central processing unit (CPU), a microprocessor (μP), or other processor. Figure 1 The methods / steps S110-S140 in the illustrated embodiment, and the corresponding technical effects achieved by the methods / steps in the illustrated example, are not described in detail herein for brevity. Figures 1 to 6 The methods / steps S110-S140 in the illustrated embodiment, and the corresponding technical effects achieved by the methods / steps in the illustrated example, are not described in detail herein for brevity.

[0206] In some examples, the electronic device 800 can further include a communication interface 803 and a bus 810. As shown, the processor 801, the memory 802, and the communication interface 803 are connected by the bus 810 and complete communication therebetween. Figure 8

[0207] The communication interface 803 is mainly used to realize the communication between various modules, devices, units, and / or equipment in the embodiments of the present application.

[0208] In addition, in combination with the test data generation method in the above-mentioned embodiments, the embodiments of the present application can provide a computer readable storage medium to implement. The computer readable storage medium has computer program instructions stored thereon; the computer program instructions are executed by the processor to implement any one of the test data generation methods in the above-mentioned embodiments.

[0209] The present application also provides a computer program product, the instructions in the computer program product are executed by the processor of the electronic device, so that the electronic device executes each process of the test data generation method embodiment.

[0210] Examples of the computer readable storage medium include non-transitory computer readable storage media such as a portable disc, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, etc.

[0211] ​It is to be understood that the application is not limited to particular configurations and processes described herein and shown in the drawings. For simplicity, detailed descriptions of known methods and apparatuses are omitted so as not to obscure the disclosure. In the above-described embodiments, several specific steps are described as examples. However, the method processes of the present application are not limited to the specific steps described and illustrated herein, but can include any number of additional steps or changes to the described steps, or can be performed in any order, or in parallel, depending on the circumstances.

[0212] The functional blocks shown in the structural block diagrams described above can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, and the like. When implemented in software, the elements of the present application are program or code segments used to perform the required tasks. The program or code segments can be stored in a machine-readable medium or transmitted through a data signal carried in a carrier wave over a transmission medium or communication link. The "machine-readable medium" can include any medium capable of storing or transmitting information. Examples of the machine-readable medium include electronic circuits, semiconductor memory devices, read-only memory (ROM), flash memory, erasable read-only memory (EROM), floppy disks, compact discs (CD-ROM), optical disks, hard disks, optical fiber media, radio frequency (RF) links, and the like. The code segments can be downloaded via a computer network such as the Internet, an intranet, and the like.

[0213] It is also to be understood that the exemplary embodiments mentioned in the present application describe some methods or systems based on a series of steps or devices. However, the present application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiments, or in an order different from the embodiments, or several steps can be performed simultaneously.

[0214] The computer program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other processing device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other processing device to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks.

[0215] The above only describes specific implementation of the present application. For the convenience and brevity of description, the specific working processes of the above-described system, module and unit can refer to the corresponding processes in the foregoing method embodiments, which will not be described herein. It should be understood that the protection scope of the present application is not limited in this way. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical range disclosed in the present application, and these modifications or replacements should be covered by the protection scope of the present application.

Claims

1. A method for generating test data, characterized in that, include: Multiple target record contents are obtained from the test data rule table. The test data rule table is a rule table generated based on the relationship between the physical primary keys and physical foreign keys of multiple database tables. Each target record includes field type, data source information, test data generation rule information corresponding to the data source, and number of records. For each target record, a first table is created based on the field type, and the first table includes the field type; For each target record, a test data table is generated based on the data source information, the test data generation rule information, the number of records, and a first table generated based on the field type. Based on the relationships between the physical primary keys and physical foreign keys of the multiple database tables, test data is obtained by combining multiple test data tables; The data source information includes one of the following: database serial number, information obtained from the production environment or manually simulated data, and equivalent information; the test data generation rule information includes at least one of the following: self-incrementing, distributed, random, random fixed-length unique, and equivalent padding. The distribution includes one of the following: Poisson distribution, average distribution, normal distribution, left-skewed distribution, right-skewed distribution, binomial distribution, and multinomial distribution; The method further includes, prior to retrieving the target record content from the test data rule table: Obtain multiple database tables, wherein the multiple database tables include at least one of the following: participant information, contract, condition, product, location, category, business direction, event, and resource item database; Based on the relationships between the physical primary keys and physical foreign keys of the multiple database tables, the data generation order in the test data rule table is determined; Data is retrieved from the corresponding database tables according to the generation order to generate the test data rule table; The relationships between the physical primary keys and physical foreign keys of the multiple database tables include: user-defined relationships between the physical primary keys and physical foreign keys of the multiple database tables; The data source information, the test data generation rule information corresponding to the data source, and the number of records include: User-defined data source information, test data generation rules information corresponding to the data source, and number of records.

2. The test data generation method according to claim 1, characterized in that, When the data source information includes a database sequence number and the test data generation rule is auto-incrementing, for each target record, generating a test data table based on the data source information, the test data generation rule information, the number of records, and a first table generated based on the field type includes: For each target record, an auto-incrementing sequence number of the record number is obtained from the database table based on the database sequence number. Retrieve the number of records corresponding to the number of records from the database table corresponding to the auto-incrementing sequence number; Insert the auto-incrementing sequence number and the data into the first table to obtain the test data table.

3. The test data generation method according to claim 1, characterized in that, When the data source information includes information obtained from the production environment or manually simulated data, and the test data generation rule is distributed, for each target record, the process of generating a test data table based on the data source information, the test data generation rule information, the number of records, and the generation of a first table based on the field type includes: For each target record, retrieve the number of records corresponding to the specified number from the database table; The data is inserted into the first table according to the distribution rules to obtain the test data table.

4. The test data generation method according to claim 1, characterized in that, When the data source information includes information obtained from the production environment or manually simulated data, and the test data generation rule is random, fixed-length, and unique, for each target record, the process of generating a test data table based on the data source information, the test data generation rule information, the number of records, and the generation of a first table based on the field type includes: For each target record, retrieve the number of records corresponding to the specified number from the database table; Randomly replace a segment of characters in the data corresponding to the number of records to generate target test data corresponding to the number of records; The target test data is inserted into the first table to obtain the test data table.

5. The test data generation method according to claim 1, characterized in that, When the data source information includes information obtained from the production environment or manually simulated data, and the test data generation rule is random, for each target record, the process of generating a test data table based on the data source information, the test data generation rule information, the number of records, and the generation of a first table based on the field type includes: For each target record, retrieve the number of records corresponding to the specified number from the database table; Randomly replace all characters in the data corresponding to the number of records to generate target test data corresponding to the number of records; The target test data is inserted into the first table to obtain the test data table.

6. The test data generation method according to claim 1, characterized in that, When the data source information includes equivalent information and the test data generation rule is equivalent fill, for each target record, the process of generating a test data table based on the data source information, the test data generation rule information, the number of records, and the generation of a first table based on the field type includes: For each target record, retrieve the number of records corresponding to the specified number from the database table; The data corresponding to the number of records is randomly sorted to generate target test data corresponding to the number of records. The target test data is inserted into the first table to obtain the test data table.

7. The test data generation method according to claim 1, characterized in that, When the data source information includes equivalent information and the test data generation rule is distributed, for each target record, the process of generating a test data table based on the data source information, the test data generation rule information, the number of records, and the generation of a first table based on the field type includes: For each target record, retrieve the number of records corresponding to the specified number from the database table; The data is inserted into the first table according to the distribution rules to obtain the test data table.

8. The test data generation method according to any one of claims 1 to 7, characterized in that, After generating the test data, the method further includes: Delete the test data table.

9. A test data generation device, characterized in that, The device includes: The acquisition module is used to acquire multiple target record contents from the test data rule table. The test data rule table is a rule table generated based on the relationship between the physical primary keys and physical foreign keys of multiple database tables. Each target record includes field type, data source information, test data generation rule information corresponding to the data source, and the number of records. A generation module is used to create a first table for each target record based on the field type, wherein the first table includes the field type; The generation module is also used to generate a test data table for each target record based on the data source information, the test data generation rule information, the number of records, and the first table generated based on the field type. The generation module is also used to combine multiple test data tables to obtain test data based on the relationship between the physical primary keys and physical foreign keys of the multiple database tables; The data source information includes one of the following: database serial number, information obtained from the production environment or manually simulated data, and equivalent information; the test data generation rule information includes at least one of the following: self-incrementing, distributed, random, random fixed-length unique, and equivalent padding. The distribution includes one of the following: Poisson distribution, average distribution, normal distribution, left-skewed distribution, right-skewed distribution, binomial distribution, and multinomial distribution; The device further includes: The database table acquisition module is used to acquire multiple database tables before acquiring the target record content from the test data rule table. The multiple database tables include at least one of the following: participant information, contract, condition, product, location, category, business direction, event, and resource item data tables. The test data rule table generation module is used to determine the data generation order in the test data rule table based on the relationship between the physical primary keys and physical foreign keys of the multiple database tables; and to obtain data from the corresponding database tables according to the generation order to generate the test data rule table. The relationships between the physical primary keys and physical foreign keys of the multiple database tables include: user-defined relationships between the physical primary keys and physical foreign keys of the multiple database tables; The data source information, the test data generation rule information corresponding to the data source, and the number of records include: User-defined data source information, test data generation rules information corresponding to the data source, and number of records.

10. A test data generation device, characterized in that, The device includes: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, it implements the test data generation method as described in any one of claims 1-8.

11. A computer storage medium, characterized in that, The computer storage medium stores computer program instructions, which, when executed by a processor, implement the test data generation method as described in any one of claims 1-8.

12. A computer program product, characterized in that, When the instructions in the computer program product are executed by the processor of the electronic device, the electronic device causes the electronic device to perform the steps of the test data generation method as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Automatic generation method and device for testing data of database and testing system

    CN105512042A

  • Test data generation method and device, computer equipment and readable storage medium

    CN109815252A