CN117493206A - Test data generation method, device, equipment and storage medium - Google Patents

Test data generation method, device, equipment and storage medium Download PDF

Info

Publication number
CN117493206A
CN117493206A CN202311560033.7A CN202311560033A CN117493206A CN 117493206 A CN117493206 A CN 117493206A CN 202311560033 A CN202311560033 A CN 202311560033A CN 117493206 A CN117493206 A CN 117493206A
Authority
CN
China
Prior art keywords
field
dictionary
fields
test data
value corresponding
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311560033.7A
Other languages
Chinese (zh)
Inventor
李明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
ICBC Technology Co Ltd
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
ICBC Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC, ICBC Technology Co Ltd filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202311560033.7A priority Critical patent/CN117493206A/en
Publication of CN117493206A publication Critical patent/CN117493206A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/215Improving data quality; Data cleansing, e.g. de-duplication, removing invalid entries or correcting typographical errors
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Quality & Reliability (AREA)
  • Computer Hardware Design (AREA)
  • Software Systems (AREA)
  • Test And Diagnosis Of Digital Computers (AREA)

Abstract

The present disclosure provides a test data generating method, apparatus, device, and storage medium, which may be applied to the technical field of data processing, the technical field of finance, or other related fields. The method comprises the following steps: reading each field and field information corresponding to the field in the target data table; obtaining an initial field value corresponding to the field according to the field rule and the field type of each field, wherein the field information comprises the field type; re-assigning values of dictionary fields in the fields based on dictionary rules to obtain dictionary values corresponding to each dictionary field; reassigning the fields related to the logic rules in each field to obtain field values corresponding to each field; and generating test data according to each field and the field value corresponding to the field.

Description

Test data generation method, device, equipment and storage medium
Technical Field
The present disclosure relates to the field of data processing technology, financial technology, or other related fields, and more particularly, to a test data generation method, apparatus, device, medium, and program product.
Background
During the test, it is often encountered that the test is performed for 1 minute, but the test data needs to be constructed for 1 hour, and 10 tables of data need to be constructed for verifying 1 faulty bug. With the current high-speed development of middle-stage and service, the design of a service end is more and more complex, the magnitude of a database is also increased, the construction of test data is more time-consuming and labor-consuming, and a general test data generation method is needed to release manpower.
However, in the related art, the method for generating the test data has the problems of low efficiency, more dependence, poor availability and the like in creating the test data.
Disclosure of Invention
In view of the foregoing, the present disclosure provides a test data generation method, apparatus, device, medium, and program product.
According to a first aspect of the present disclosure, there is provided a test data generation method, including:
reading each field in the target data table and field information corresponding to the field;
obtaining an initial field value corresponding to each field according to a field rule and a field type of each field, wherein the field information comprises the field type;
re-assigning values of dictionary fields in the fields based on dictionary rules to obtain dictionary values corresponding to each dictionary field;
reassigning the fields related to the logic rules in each of the fields to obtain field values corresponding to each of the fields; and
and generating test data according to each field and the field value corresponding to the field.
According to an embodiment of the present disclosure, the obtaining, according to a field rule and a field type of each of the fields, an initial field value corresponding to the field includes:
For each of the fields, filtering the field if the field type of the field characterizes a self-increment field;
determining an initial field value corresponding to the field according to the character length of the field under the condition that the field type of the field represents the character type;
determining an initial field value corresponding to the field according to the number of bits of the field under the condition that the field type of the field represents integer;
under the condition that the field type of the field represents the value type, adding and subtracting the field within the target value to obtain an initial field value corresponding to the field;
in the case of the field type characterization date field of the above field, the date is added to the initial date of the above field to obtain an initial field value corresponding to the above field.
According to an embodiment of the present disclosure, the reassigning values of dictionary fields in the fields based on dictionary rules to obtain dictionary values corresponding to each of the dictionary fields includes:
determining dictionary values corresponding to the dictionary fields according to the dictionary rules when the fields represent the dictionary fields; and
And reassigning the initial field value corresponding to the dictionary field by using the dictionary value corresponding to the dictionary field to obtain the reassigned dictionary value.
According to an embodiment of the present disclosure, reassigning the fields related to the logic rule in each of the fields to obtain field values corresponding to each of the fields includes:
for each field, reassigning the value of the field under the condition that the field has a size relation with the associated field, so as to obtain a field value corresponding to the field;
and when the field has business meaning, reassigning the value of the field according to the associated field corresponding to the field to obtain the field value corresponding to the field.
According to an embodiment of the present disclosure, the generating test data according to each of the fields and the field values corresponding to the fields includes:
generating a stored script according to each field, a field value corresponding to the field and the number of test data to be constructed; and
executing the stored script to generate the test data.
According to an embodiment of the present disclosure, the executing the stored script generates the test data, including:
Executing the stored script, and inserting the generated test data into a database.
According to an embodiment of the present disclosure, the test data generating method further includes:
storing the stored script into a stored file;
and deleting the test data constructed in the database.
A second aspect of the present disclosure provides a test data generating apparatus, including: the device comprises a reading module, a first obtaining module, a second obtaining module, a third obtaining module and a generating module. And the reading module is used for reading each field in the target data table and the field information corresponding to the field. And the first obtaining module is used for obtaining an initial field value corresponding to each field according to a field rule and a field type of each field, wherein the field information comprises the field type. And the second obtaining module is used for reassigning the values of the dictionary fields in the fields based on dictionary rules to obtain dictionary values corresponding to each dictionary field. And a third obtaining module, configured to reassign a field related to a logic rule in each of the fields to obtain a field value corresponding to each of the fields. And the generating module is used for generating test data according to each field and the field value corresponding to the field.
A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method described above.
A fourth aspect of the present disclosure also provides a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the above-described method.
A fifth aspect of the present disclosure also provides a computer program product comprising a computer program which, when executed by a processor, implements the above method.
According to the test data generation method, device, equipment, medium and program product, the initial field value corresponding to the field can be generated through the field rule, the dictionary field is reassigned based on the dictionary rule to obtain the dictionary value, and then the field related to the logic rule is reassigned, so that the field value corresponding to each field can be obtained, the test data can be quickly generated according to the field and the corresponding field value, the labor cost of the test personnel for inputting the data construction is reduced to a certain extent, the efficiency of the test data is improved, the method is universal and flexible, and the method is applicable to all projects and products and has higher customization degree.
Drawings
The foregoing and other objects, features and advantages of the disclosure will be more apparent from the following description of embodiments of the disclosure with reference to the accompanying drawings, in which:
FIG. 1 schematically illustrates an application scenario diagram of a test data generation method according to an embodiment of the present disclosure;
FIG. 2 schematically illustrates a flow chart of a test data generation method according to an embodiment of the disclosure;
FIG. 3 schematically illustrates a flow chart of deriving an initial field value according to an embodiment of the present disclosure;
FIG. 4 schematically illustrates a functional block diagram for implementing a test data generation method according to an embodiment of the present disclosure;
FIG. 5 schematically shows a block diagram of a test data generating device according to an embodiment of the present disclosure; and
fig. 6 schematically illustrates a block diagram of an electronic device adapted to implement a test data generation method according to an embodiment of the disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is only exemplary and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the present disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. In addition, in the following description, descriptions of well-known structures and techniques are omitted so as not to unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and/or the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It should be noted that the terms used herein should be construed to have meanings consistent with the context of the present specification and should not be construed in an idealized or overly formal manner.
Where expressions like at least one of "A, B and C, etc. are used, the expressions should generally be interpreted in accordance with the meaning as commonly understood by those skilled in the art (e.g.," a system having at least one of A, B and C "shall include, but not be limited to, a system having a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
In the technical scheme of the invention, the related user information (including but not limited to user personal information, user image information, user equipment information, such as position information and the like) and data (including but not limited to data for analysis, stored data, displayed data and the like) are information and data authorized by a user or fully authorized by all parties, and the processing of the related data such as collection, storage, use, processing, transmission, provision, disclosure, application and the like are all conducted according to the related laws and regulations and standards of related countries and regions, necessary security measures are adopted, no prejudice to the public welfare is provided, and corresponding operation inlets are provided for the user to select authorization or rejection.
In practicing the present disclosure, it was found that there are methods of generating existing test data that directly generate interface test data according to GUI (Graphical User Interface ) operations; there is a call to production test data through the API (Application Program Interface ); there is a direct insert database table to generate test data.
Wherein, the defects of the existence of the interface test data directly generated according to the GUI operation include: the efficiency of creating test data is very low, operations need to be performed on pages, and only 1 piece of data can be generated at a time; the quality of test data can be affected by more dependence on the creation of test data, such as service anomalies, interface changes, and accuracy of data entry.
Among the disadvantages of producing test data through API calls include: not all test data is supported by the corresponding API, additional development is required, and a piece of data may need to be passed between multiple API calls; the creation efficiency is low, and for scenes needing to create mass data in batches, the creation cannot be completed.
The defects of directly inserting the database table to generate the test data include: lack of business logic and poor data availability; creation is inefficient and requires redesigning the data each time.
To this end, an embodiment of the present disclosure provides a test data generation method, including: reading each field and field information corresponding to the field in the target data table; obtaining an initial field value corresponding to the field according to the field rule and the field type of each field, wherein the field information comprises the field type; re-assigning values of dictionary fields in the fields based on dictionary rules to obtain dictionary values corresponding to each dictionary field; reassigning the fields related to the logic rules in each field to obtain field values corresponding to each field; and generating test data according to each field and the field value corresponding to the field.
Fig. 1 schematically illustrates an application scenario diagram of a test data generation method according to an embodiment of the present disclosure.
As shown in fig. 1, an application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is a medium used to provide a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The user may interact with the server 105 through the network 104 using at least one of the first terminal device 101, the second terminal device 102, the third terminal device 103, to receive or send messages, etc. Various communication client applications, such as a shopping class application, a web browser application, a search class application, an instant messaging tool, a mailbox client, social platform software, etc. (by way of example only) may be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103.
The first terminal device 101, the second terminal device 102, the third terminal device 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 105 may be a server providing various services, such as a background management server (by way of example only) providing support for websites browsed by the user using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as the user request, and feed back the processing result (e.g., the web page, information, or data obtained or generated according to the user request) to the terminal device.
For example, the server 105 may read each field and the field information corresponding to the field in the target data table, obtain an initial field value corresponding to the field according to the field rule and the field type of each field, reassign the value of the dictionary field in the field based on the dictionary rule to obtain a dictionary value corresponding to each dictionary field, reassign the field related to the logic rule in each field to obtain a field value corresponding to each field, thereby generating the test data according to each field and the field value corresponding to the field.
It should be noted that the test data generating method provided by the embodiments of the present disclosure may be generally performed by the server 105. Accordingly, the test data generating device provided by the embodiments of the present disclosure may be generally provided in the server 105. The test data generation method provided by the embodiments of the present disclosure may also be performed by a server or a server cluster that is different from the server 105 and is capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and/or the server 105. Accordingly, the test data generating apparatus provided by the embodiments of the present disclosure may also be provided in a server or a server cluster that is different from the server 105 and is capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and/or the server 105.
It should be understood that the number of terminal devices, networks and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
The test data generation method of the disclosed embodiment will be described in detail below with reference to fig. 2 to 4 based on the scenario described in fig. 1.
Fig. 2 schematically illustrates a flow chart of a test data generation method according to an embodiment of the present disclosure.
As shown in fig. 2, the method 200 includes operations S210 to S250.
In operation S210, each field in the target data table and field information corresponding to the field are read.
According to embodiments of the present disclosure, a target data table may characterize all or a portion of the data tables required in a target database, where the target database may include MySQL, oracle, etc., and the target data table may include at least one data table.
According to the embodiment of the disclosure, the selected target database is connected, a required target data table is selected in the target database, and each field in the target data table and field information corresponding to the field can be read through two modes of database import and file import.
Wherein, file import refers to reading DDL files of the target database.
According to an embodiment of the present disclosure, the field information may include a field name, a field chinese name, a field type, a field length, whether to self-increment, whether to not blank, whether to enter a key, and the like, and may further include a table name corresponding to the data table.
According to embodiments of the present disclosure, the read field information may be added to a field table.
In operation S220, an initial field value corresponding to the field is obtained according to the field rule and the field type of each field.
According to an embodiment of the present disclosure, the field information may include a field type. The field rules may characterize set field value rules corresponding to different field types.
According to embodiments of the present disclosure, initial field values for fields of different field types may be determined according to field rules, where the field rules may apply to all fields.
In operation S230, values of dictionary fields among the fields are reassigned based on the dictionary rules, resulting in dictionary values corresponding to each dictionary field.
According to embodiments of the present disclosure, the fields may also characterize dictionary fields, and the dictionary rules may characterize rules generated from a dictionary table, where dictionary values corresponding to different dictionary fields may be included in the dictionary table, and the dictionary rules may apply to all dictionary fields. According to embodiments of the present disclosure, where the field is a dictionary field, the initial field value of the previous assignment is invalidated, requiring reassignment with the corresponding dictionary value.
In operation S240, a field related to the logic rule in each field is reassigned to obtain a field value corresponding to each field.
According to embodiments of the present disclosure, logic rules may characterize rules that maintain a dictionary for logic that exists between fields. The logic rule is determined according to a logic table, wherein the logic table can comprise logic values corresponding to different business meanings.
According to the embodiment of the disclosure, the associated fields with inconsistent field names can be maintained according to the logic rules, the business meaning of the fields with business meaning is maintained, the size of the associated amount of money is maintained, the size of the associated date is maintained, and the fixed value and the null value can be maintained so as to reassign the fields related to the logic rules again, thereby obtaining the field value corresponding to each field.
In operation S250, test data is generated according to each field and a field value corresponding to the field.
According to the embodiment of the disclosure, the test data may be generated according to each field, a field value corresponding to the field, and field information of each field.
According to the embodiment of the disclosure, the initial field value corresponding to the field can be generated through the field rule, the dictionary field is reassigned based on the dictionary rule to obtain the dictionary value, and then the field related to the logic rule is reassigned, so that the field value corresponding to each field can be obtained, test data can be quickly generated according to the field and the corresponding field value, the labor cost of the test personnel for inputting the data construction is reduced to a certain extent, the efficiency of the test data is improved, and the method is universal and flexible, and is applicable to simultaneous customization of all projects and products to a higher degree.
Fig. 3 schematically illustrates a flow chart of deriving an initial field value according to an embodiment of the present disclosure.
As shown in fig. 3, the method 300 includes operations S310 to S350.
In operation S310, for each field, in the case where the field type of the field characterizes the self-increment field, the field is filtered.
According to an embodiment of the present disclosure, the self-increment field is set to be not processed, i.e., an initial value is not given to the self-increment field, and the self-increment field is filtered.
In operation S320, in case that the field type of the field characterizes the character type, an initial field value corresponding to the field is determined according to the character length of the field.
According to embodiments of the present disclosure, for a field of a character type, an initial field value corresponding to the field may be determined according to a character length of the field.
For example, the initial value may be 1000000000, and when the character length is smaller than 10, the number of bits of the next 0 is 1, and the number of bits of the next 0 is one bit less than the character length, that is, the character length is reduced by several characters compared with 10, and the number of bits of the next 0 is reduced by several. For example, PROD_TYPE varchar (3), the initial field value of this field will be set to 100.
In operation S330, in case that the field type of the field characterizes the integer, an initial field value corresponding to the field is determined according to the number of bits of the field.
According to embodiments of the present disclosure, for an integer field, an initial field value corresponding to the field may be determined according to the number of bits of the field.
For example, the initial value may be set to 10000, and if the number of bits in the field is smaller than 5 bits, the number of bits is 1, followed by 0, which is one bit less than the character length.
In operation S340, in the case where the field type of the field characterizes the value type, the field is subjected to addition and subtraction within the target value, and an initial field value corresponding to the field is obtained.
According to the embodiment of the disclosure, for a field of a value type, an initial value of the set field may be subjected to addition and subtraction within a target value to obtain an initial field value corresponding to the field. Wherein the target value may be randomly set, such as 100.
For example, the initial value may be set to 10000.22, and the corresponding field value may be obtained by adding or subtracting the random value within 100 to or from the initial value.
In operation S350, in case that the field type of the field characterizes the date field, an increase of date is performed on the initial date of the field, resulting in an initial field value corresponding to the field.
According to the embodiment of the disclosure, for the field of the date type, the date may be increased based on the set initial date, so as to obtain an initial field value corresponding to the field.
For example, an initial date may be set to 20220404 on which an increase in date is made, e.g., 1 month each time.
According to embodiments of the present disclosure, an initial field value of 1 may also be set for a field of the char (1), int (1) type.
According to the embodiment of the disclosure, the fields with different field types can be subjected to general maintenance through the set field rules, and all the fields are assigned with initial field values.
According to an embodiment of the present disclosure, reassigning values of dictionary fields in the fields based on dictionary rules to obtain dictionary values corresponding to each dictionary field includes: under the condition that the fields represent dictionary fields, determining dictionary values corresponding to the dictionary fields according to dictionary rules; and reassigning the initial field value corresponding to the dictionary field by using the dictionary value corresponding to the dictionary field to obtain the reassigned dictionary value.
According to the embodiment of the disclosure, in the case that a field can represent a dictionary field, a dictionary value corresponding to the field can be determined according to a dictionary rule, so that an initial field value of the dictionary field is reassigned, and a reassigned dictionary value is obtained.
For example, a field of field length 1 in the scan field table may automatically generate dictionary values 0,1.
According to embodiments of the present disclosure, manual addition of dictionary values may also be supported, such as if a field is a character type, but if the field is only supported by 100, 200, 300, then the field may be manually maintained as a dictionary value.
According to embodiments of the present disclosure, initial field values of dictionary fields may be modified with corresponding random dictionary values according to dictionary rules, such that the corresponding dictionary values may be overlaid with the original initial field values.
According to an embodiment of the present disclosure, reassigning a field related to a logic rule in each field to obtain a field value corresponding to each field includes: for each field, under the condition that the field and the associated field have a size relationship, reassigning the value of the field to obtain a field value corresponding to the field; and under the condition that the field has business meaning, reassigning the value of the field according to the associated field corresponding to the field to obtain the field value corresponding to the field.
According to the embodiment of the disclosure, when a size relation exists between a field and an associated field, the value of the field can be reassigned according to the size relation, so as to obtain a field value corresponding to the field.
According to the embodiment of the disclosure, in the case that the field is an amount field, the amount field has a size relationship, and a logic relationship of an associated field corresponding to the amount field, for example, a guarantee of < principal; interest is less than 1.
According to an embodiment of the present disclosure, in the case where a field is a date field, a logical relationship of an associated field corresponding to the date field, such as release date < expiration date < payment date < expiration date, may be set.
According to the embodiment of the disclosure, in the case that the field has a business meaning, the value of the field can be reassigned according to the associated field corresponding to the field, so as to obtain the field value corresponding to the field.
According to an embodiment of the present disclosure, in the case where table names of two data tables are not identical, but meanings and values are identical, a rule may be added, for example, XX field of table 1=xx field of table 2.
According to the embodiment of the disclosure, when a character field defaults to 1, and a certain field is to be modified to start with two GZ letters, the value manner of the field may be modified, for example, setting GZ start, followed by 10000000, or 1XX, where XX is a character length of-3 0.
According to the embodiment of the disclosure, under the condition that certain fields have business meanings, the XX field of the XX table is XX condition, the XX field of the XX table must XX, and a condition value statement can be defined.
According to embodiments of the present disclosure, the remark field may also be set to XXX number of manufacture, the modification point may be set to null, and so on.
According to the embodiment of the disclosure, under the condition that a logic relationship exists between the fields and the related fields, the values of the fields can be assigned again according to the logic rules, so that the logic correctness among the fields is ensured, and the accuracy of generating the test data is further improved.
According to an embodiment of the present disclosure, generating test data according to each field and a field value corresponding to the field includes: generating a stored script according to each field, the field value corresponding to the field and the quantity of test data to be constructed; executing the stored script and generating test data.
According to the embodiment of the disclosure, the generated field value corresponding to the field can be saved as stored SQL, and browsing, modification and saving can be supported.
According to the embodiment of the disclosure, the saved field and the corresponding field value can be selected, and the number of test data to be constructed, that is, the number of test data to be constructed, is input to generate the stored script. In the case where execution of the stored script is successful, test data may be generated.
The generated stored script may support the downloading, modification and execution of the stored script.
According to the embodiment of the disclosure, the corresponding stored script can be generated according to the generated field value and the number of the test data required to be constructed, so that the stored script is executed to quickly generate the required number of the test data. According to an embodiment of the present disclosure, executing a stored script generates test data, including: executing the stored script, and inserting the generated test data into a database.
According to an embodiment of the present disclosure, the script-based process is performed by inserting the generated test data into a database, that is, inserting the generated test data into a corresponding data table.
According to an embodiment of the present disclosure, the generated test data is inserted into a database so that a data table can be tested according to the test data.
According to an embodiment of the present disclosure, the test data generating method further includes: storing the stored script into a stored file; and deleting the test data constructed in the database.
According to the embodiment of the disclosure, the stored script can be stored in the stored file for subsequent repeated calling, and test data are generated in batches according to the stored file; after the test data is generated for testing, the constructed test data can be deleted, and dirty data in the database is reduced.
Fig. 4 schematically illustrates a functional block diagram for implementing a test data generation method according to an embodiment of the present disclosure.
As shown in fig. 4, the functional block diagram 400 may include an import module 410, a data maintenance module 420, a data generation module 430, and a test data cleansing module 440.
According to an embodiment of the present disclosure, the above-described operation S210 may be performed by the import module 410 to read each field and field information corresponding to each field in the resulting target data table.
According to embodiments of the present disclosure, the data maintenance module 420 may include a field general maintenance module 421, a dictionary maintenance module 422, and a field logic maintenance module 423. General maintenance can be performed for different types of field value rules by the field general maintenance module 421. Dictionary fields may be maintained by dictionary maintenance module 422. The logical rules of the fields may be maintained by the field logic maintenance module 423.
According to an embodiment of the present disclosure, the data generation module 430 may include a field value generation module 431 and a test data generation module 432.
According to an embodiment of the present disclosure, the above-described operations S220 to S240 may be performed according to the field value generation module 431 according to contents in the field general maintenance module 421, the dictionary maintenance module 422, and the field logic maintenance module 423 to generate a field value corresponding to each field.
According to an embodiment of the present disclosure, the field value generating module 431 may be used to scan the field table, and generate field initial values of all fields according to the rules of the field general maintenance module 421, for example, the product number field generates 1000000000+i, the amount generates 10050.55 (10000.22 +random number), the date generates 20220404, the same table has multiple dates, which may increase with a frequency of one month, for example, the start date is 20220404, the end date is 20220504 (20220404+1 month), and the date remains unchanged in iteration date.
According to an embodiment of the present disclosure, after all the fields generate field initial values, the dictionary table is scanned again, and the field initial values of the dictionary fields are modified according to the dictionary rules of the dictionary maintenance module 422, and the initial values are randomly taken dictionary values.
According to an embodiment of the present disclosure, after the dictionary value processing, the field logic table in the field logic maintenance module 423 is read, the logic rule of the field is processed, the logic statement is placed after the dictionary value assignment statement, and the field involved in the rule is reassigned to the initial value. And after generating the field logic statement, generating an insert statement of the data table.
According to an embodiment of the present disclosure, the above-described operation S250 may be performed according to the test data generation module 432 to generate test data.
According to embodiments of the present disclosure, the constructed test data may be deleted after testing with the test data by the test data cleansing module 440.
Based on the test data generation method, the disclosure also provides a test data generation device. The device will be described in detail below in connection with fig. 5.
Fig. 5 schematically shows a block diagram of a test data generating apparatus according to an embodiment of the present disclosure.
As shown in fig. 5, the test data generating apparatus 500 of this embodiment includes a reading module 510, a first obtaining module 520, a second obtaining module 530, a third obtaining module 540, and a generating module 550.
The reading module 510 is configured to read each field in the target data table and field information corresponding to the field. In an embodiment, the reading module 510 may be configured to perform the operation S210 described above, which is not described herein.
The first obtaining module 520 is configured to obtain an initial field value corresponding to the field according to the field rule and the field type of each field, where the field information includes the field type. In an embodiment, the first obtaining module 520 may be used to perform the operation S220 described above, which is not described herein.
The second obtaining module 530 is configured to reassign values of dictionary fields in the fields based on dictionary rules, to obtain dictionary values corresponding to each dictionary field. In an embodiment, the second obtaining module 530 may be used to perform the operation S230 described above, which is not described herein.
The third obtaining module 540 is configured to reassign the fields related to the logic rule in each field to obtain a field value corresponding to each field. In an embodiment, the third obtaining module 540 may be used to perform the operation S240 described above, which is not described herein.
The generating module 550 is configured to generate test data according to each field and a field value corresponding to the field. In an embodiment, the generating module 550 may be configured to perform the operation S250 described above, which is not described herein.
According to an embodiment of the present disclosure, the first obtaining module 520 includes a filtering unit, a first determining unit, a second determining unit, a first obtaining unit, and a second obtaining unit.
And a filtering unit, configured to filter, for each field, the field if the field type of the field characterizes the self-increment field.
And the first determining unit is used for determining an initial field value corresponding to the field according to the character length of the field when the field type of the field represents the character type.
And the second determining unit is used for determining an initial field value corresponding to the field according to the bit number of the field under the condition that the field type of the field represents integer.
The first obtaining unit is used for adding or subtracting the field within the target value under the condition that the field type of the field represents the value type, so as to obtain an initial field value corresponding to the field.
And the second obtaining unit is used for increasing the date on the initial date of the field to obtain an initial field value corresponding to the field under the condition that the field type of the field characterizes the date field.
According to an embodiment of the present disclosure, the second obtaining module 530 includes a third determining unit and a third obtaining unit.
And a third determining unit for determining dictionary values corresponding to the dictionary fields according to dictionary rules in the case of field representation dictionary fields.
And the third obtaining unit is used for reassigning the initial field value corresponding to the dictionary field by utilizing the dictionary value corresponding to the dictionary field to obtain the reassigned dictionary value.
According to an embodiment of the present disclosure, the third obtaining module 540 includes a fourth obtaining unit and a fifth obtaining unit.
And a fourth obtaining unit, configured to reassign, for each field, a value of the field to obtain a field value corresponding to the field when the field has a size relationship with the associated field.
And a fifth obtaining unit, configured to reassign the value of the field according to the associated field corresponding to the field to obtain the field value corresponding to the field when the field has the business meaning.
According to an embodiment of the present disclosure, the generation module 550 includes a first generation unit and a second generation unit.
The first generation unit is used for generating a stored script according to each field, the field value corresponding to the field and the quantity of test data to be constructed.
And the second generation unit is used for executing the stored script and generating test data.
According to an embodiment of the present disclosure, the second generation unit comprises an insertion subunit.
And the inserting subunit is used for executing the stored script and inserting the generated test data into the database.
According to an embodiment of the present disclosure, the second generating unit further comprises a save subunit and a delete subunit.
And the storage subunit is used for storing the stored script into the stored file.
And the deleting subunit is used for deleting the test data constructed in the database.
According to an embodiment of the present disclosure, any of the plurality of modules of the reading module 510, the first obtaining module 520, the second obtaining module 530, the third obtaining module 540, and the generating module 550 may be combined in one module to be implemented, or any of the plurality of modules may be split into a plurality of modules. Alternatively, at least some of the functionality of one or more of the modules may be combined with at least some of the functionality of other modules and implemented in one module. According to embodiments of the present disclosure, at least one of the reading module 510, the first obtaining module 520, the second obtaining module 530, the third obtaining module 540, and the generating module 550 may be implemented at least in part as hardware circuitry, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in hardware or firmware in any other reasonable way of integrating or packaging the circuitry, or in any one of or a suitable combination of any of the three implementations of software, hardware, and firmware. Alternatively, at least one of the reading module 510, the first obtaining module 520, the second obtaining module 530, the third obtaining module 540, and the generating module 550 may be at least partially implemented as a computer program module, which when executed may perform the respective functions.
Fig. 6 schematically illustrates a block diagram of an electronic device adapted to implement a test data generation method according to an embodiment of the disclosure.
As shown in fig. 6, an electronic device 600 according to an embodiment of the present disclosure includes a processor 601 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. The processor 601 may include, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or an associated chipset and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), or the like. Processor 601 may also include on-board memory for caching purposes. The processor 601 may comprise a single processing unit or a plurality of processing units for performing different actions of the method flows according to embodiments of the disclosure.
In the RAM 603, various programs and data necessary for the operation of the electronic apparatus 600 are stored. The processor 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. The processor 601 performs various operations of the method flow according to the embodiments of the present disclosure by executing programs in the ROM 602 and/or the RAM 603. Note that the program may be stored in one or more memories other than the ROM 602 and the RAM 603. The processor 601 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in the one or more memories.
According to an embodiment of the present disclosure, the electronic device 600 may also include an input/output (I/O) interface 605, the input/output (I/O) interface 605 also being connected to the bus 604. The electronic device 600 may also include one or more of the following components connected to an input/output (I/O) interface 605: an input portion 606 including a keyboard, mouse, etc.; an output portion 607 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The drive 610 is also connected to an input/output (I/O) interface 605 as needed. Removable media 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on drive 610 so that a computer program read therefrom is installed as needed into storage section 608.
The present disclosure also provides a computer-readable storage medium that may be embodied in the apparatus/device/system described in the above embodiments; or may exist alone without being assembled into the apparatus/device/system. The computer-readable storage medium carries one or more programs which, when executed, implement methods in accordance with embodiments of the present disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example, but is not limited to: a portable computer diskette, 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, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. For example, according to embodiments of the present disclosure, the computer-readable storage medium may include ROM 602 and/or RAM 603 and/or one or more memories other than ROM 602 and RAM 603 described above.
Embodiments of the present disclosure also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowcharts. The program code, when executed in a computer system, causes the computer system to perform the methods provided by embodiments of the present disclosure.
The above-described functions defined in the system/apparatus of the embodiments of the present disclosure are performed when the computer program is executed by the processor 601. The systems, apparatus, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the disclosure.
In one embodiment, the computer program may be based on a tangible storage medium such as an optical storage device, a magnetic storage device, or the like. In another embodiment, the computer program may also be transmitted, distributed in the form of signals over a network medium, and downloaded and installed via the communication section 609, and/or installed from the removable medium 611. The computer program may include program code that may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
In such an embodiment, the computer program may be downloaded and installed from a network through the communication portion 609, and/or installed from the removable medium 611. The above-described functions defined in the system of the embodiments of the present disclosure are performed when the computer program is executed by the processor 601. The systems, devices, apparatus, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the disclosure.
According to embodiments of the present disclosure, program code for performing computer programs provided by embodiments of the present disclosure may be written in any combination of one or more programming languages, and in particular, such computer programs may be implemented in high-level procedural and/or object-oriented programming languages, and/or assembly/machine languages. Programming languages include, but are not limited to, such as Java, c++, python, "C" or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of remote computing devices, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., connected via the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Those skilled in the art will appreciate that the features recited in the various embodiments of the disclosure and/or in the claims may be provided in a variety of combinations and/or combinations, even if such combinations or combinations are not explicitly recited in the disclosure. In particular, the features recited in the various embodiments of the present disclosure and/or the claims may be variously combined and/or combined without departing from the spirit and teachings of the present disclosure. All such combinations and/or combinations fall within the scope of the present disclosure.
The embodiments of the present disclosure are described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the embodiments cannot be used advantageously in combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be made by those skilled in the art without departing from the scope of the disclosure, and such alternatives and modifications are intended to fall within the scope of the disclosure.

Claims (11)

1. A test data generation method, comprising:
reading each field in the target data table and field information corresponding to the field;
Obtaining an initial field value corresponding to each field according to a field rule and a field type of each field, wherein the field information comprises the field type;
re-assigning values of dictionary fields in the fields based on dictionary rules to obtain dictionary values corresponding to each dictionary field;
reassigning the fields related to the logic rules in each field to obtain a field value corresponding to each field; and
and generating test data according to each field and the field value corresponding to the field.
2. The method of claim 1, wherein the obtaining an initial field value corresponding to the field according to a field rule and a field type of each of the fields comprises:
for each of the fields, filtering the field if the field type of the field characterizes a self-increasing field;
determining an initial field value corresponding to the field according to the character length of the field under the condition that the field type of the field represents the character type;
under the condition that the field type of the field represents integer, determining an initial field value corresponding to the field according to the bit number of the field;
Under the condition that the field type of the field represents the value type, adding and subtracting the field within the target value to obtain an initial field value corresponding to the field;
and under the condition that the field type of the field characterizes a date field, increasing the date on the initial date of the field to obtain an initial field value corresponding to the field.
3. The method of claim 1, wherein reassigning values of dictionary fields of the fields based on dictionary rules to obtain dictionary values corresponding to each of the dictionary fields, comprises:
determining dictionary values corresponding to the dictionary fields according to the dictionary rules under the condition that the fields represent the dictionary fields; and
and reassigning the initial field value corresponding to the dictionary field by utilizing the dictionary value corresponding to the dictionary field to obtain the reassigned dictionary value.
4. The method of claim 1, wherein reassigning the fields of each of the fields that relate to the logical rule to obtain the field value corresponding to each of the fields, comprises:
for each field, under the condition that the size relation exists between the field and the associated field, reassigning the value of the field to obtain a field value corresponding to the field;
And under the condition that the field has business meaning, reassigning the value of the field according to the associated field corresponding to the field to obtain the field value corresponding to the field.
5. The method of claim 1, wherein the generating test data from each of the fields and the field values corresponding to the fields comprises:
generating a stored script according to each field, a field value corresponding to the field and the number of test data to be constructed; and
and executing the stored script to generate the test data.
6. The method of claim 5, wherein the executing the stored script generates the test data comprising:
executing the stored script, and inserting the generated test data into a database.
7. The method of claim 6, further comprising:
storing the stored script into a stored file;
and deleting the test data constructed in the database.
8. A test data generation apparatus comprising:
the reading module is used for reading each field in the target data table and the field information corresponding to the field;
the first obtaining module is used for obtaining an initial field value corresponding to each field according to a field rule and a field type of each field, wherein the field information comprises the field type;
The second obtaining module is used for reassigning the values of the dictionary fields in the fields based on dictionary rules to obtain dictionary values corresponding to each dictionary field;
the third obtaining module is used for reassigning the fields related to the logic rules in each field to obtain a field value corresponding to each field; and
and the generating module is used for generating test data according to each field and the field value corresponding to the field.
9. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of any of claims 1-7.
10. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to perform the method according to any of claims 1-7.
11. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 7.
CN202311560033.7A 2023-11-22 2023-11-22 Test data generation method, device, equipment and storage medium Pending CN117493206A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311560033.7A CN117493206A (en) 2023-11-22 2023-11-22 Test data generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311560033.7A CN117493206A (en) 2023-11-22 2023-11-22 Test data generation method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117493206A true CN117493206A (en) 2024-02-02

Family

ID=89684760

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311560033.7A Pending CN117493206A (en) 2023-11-22 2023-11-22 Test data generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117493206A (en)

Similar Documents

Publication Publication Date Title
CN109684188B (en) Test method and device
CN109101294B (en) Data acquisition method, plug-in, electronic equipment and storage medium
CN113344523A (en) Data processing method and device, electronic equipment and computer readable storage medium
CN113535577B (en) Application testing method and device based on knowledge graph, electronic equipment and medium
CN113507419B (en) Training method of traffic distribution model, traffic distribution method and device
CN115965474A (en) Service processing method, device, equipment and storage medium
CN117493206A (en) Test data generation method, device, equipment and storage medium
CN113495498B (en) Simulation method, simulator, device and medium for hardware device
CN115471228A (en) Financial business certificate checking method, device, equipment and storage medium
CN115080433A (en) Testing method and device based on flow playback
CN114115628A (en) U shield display information acquisition method, device, equipment, medium and program product applied to U shield test
CN113918525A (en) Data exchange scheduling method, system, electronic device, medium, and program product
CN113535565A (en) Interface use case generation method, device, equipment, medium and program product
CN112579428A (en) Interface testing method and device, electronic equipment and storage medium
CN113568838A (en) Test data generation method, device, equipment, storage medium and program product
CN115587045A (en) Test case generation method, device, equipment, storage medium and program product
CN117472734A (en) Test method, device, equipment and storage medium
CN116310423A (en) Image recognition method, device, electronic equipment and readable storage medium
CN114218254A (en) Report generation method, device, equipment and storage medium
CN117435472A (en) Page test method, device, equipment and medium
CN115687083A (en) Business system testing method and device, electronic equipment and storage medium
CN113656326A (en) Program testing method, program testing device, computer system and storage medium
CN116070891A (en) Flow processing method, device, equipment and storage medium
CN117806977A (en) Test method, apparatus, device, medium and program product
CN116361159A (en) Interface regression testing method, device, electronic equipment and computer readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination