CN115237783A - Test data generation method and device - Google Patents

Test data generation method and device Download PDF

Info

Publication number
CN115237783A
CN115237783A CN202210896135.5A CN202210896135A CN115237783A CN 115237783 A CN115237783 A CN 115237783A CN 202210896135 A CN202210896135 A CN 202210896135A CN 115237783 A CN115237783 A CN 115237783A
Authority
CN
China
Prior art keywords
data
field
test
dictionary
test data
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
CN202210896135.5A
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.)
Bank of China Ltd
Original Assignee
Bank of China 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 Bank of China Ltd filed Critical Bank of China Ltd
Priority to CN202210896135.5A priority Critical patent/CN115237783A/en
Publication of CN115237783A publication Critical patent/CN115237783A/en
Pending legal-status Critical Current

Links

Images

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/368Test management for test version control, e.g. updating test cases to a new software version

Abstract

The application discloses a test data generation method and a device, which can be applied to the technical field of data processing, and the method comprises the following steps: the method comprises the steps of obtaining a test case, obtaining at least one first field from a preset data dictionary according to the test case, wherein the first field is a field in a plurality of data tables corresponding to the test case, and generating test data according to the at least one first field and based on a field constraint rule which is configured in advance or generated automatically. According to the method and the device, the test data can be automatically generated based on the field constraint rule which is configured in advance or generated automatically according to the at least one first field obtained from the preset data dictionary, so that the problems that test data are manufactured manually in the prior art, but the task quantity of the number of the test data is large due to the fact that too many data tables of the test data need to be manufactured, a large amount of manpower is consumed and manpower resources are wasted due to the fact that the test data are manufactured manually are solved.

Description

Test data generation method and device
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a test data generation method.
Background
With the development of socio-economy, more and more people choose to go to banks to handle business, and the transaction times of users are increased. Hundreds of data tables may be involved in each transaction, a bank develops its own system for collecting and supervising the data tables, and the data in the data tables needs to be tested to avoid problems due to the large number of data tables, but no data in the data tables needs to be created due to some uncertain factors.
At present, test data can be manufactured manually, but because a data table for manufacturing the test data is too many, the task amount for manufacturing the test data is large, and the test data manufactured manually needs to consume a large amount of manpower, so that the manpower resource is wasted.
Therefore, how to save a large amount of manpower in the process of manufacturing test data and avoid the waste of manpower resources is a technical problem which needs to be solved urgently in the field.
Disclosure of Invention
Based on the above problems, the present application provides a test data generation method and apparatus, so as to save a lot of manpower in the process of manufacturing test data and avoid waste of human resources. The embodiment of the application discloses the following technical scheme.
In a first aspect, the present application provides a method for generating test data, including:
obtaining a test case;
acquiring at least one first field from a preset data dictionary according to the test case; the first field is a field in a plurality of data tables corresponding to the test case;
and generating test data according to the at least one first field based on a pre-configured or automatically generated field constraint rule.
Optionally, the obtaining at least one first field from a preset data dictionary according to the test case includes:
determining a plurality of data tables corresponding to the test cases according to the test cases;
and acquiring at least one field in the plurality of data tables from a preset data dictionary according to the plurality of data tables.
Optionally, before the test case, the method further includes:
establishing a data dictionary;
setting a plurality of fields through the data dictionary, and storing the set fields in the data dictionary.
Optionally, the generating test data based on a preconfigured or automatically generated field constraint rule according to the at least one first field includes:
performing duplicate removal on the at least one acquired first field to obtain a first field after duplicate removal;
and generating test data based on a field constraint rule which is configured in advance or automatically generated according to the first field after the duplication removal.
Optionally, the method further includes:
and filling the generated test data into the plurality of data tables to obtain a data table of the number of the data.
In a second aspect, the present application provides a test data generating apparatus, comprising:
the first acquisition unit is used for acquiring the test case;
the second acquisition unit is used for acquiring at least one first field from a preset data dictionary according to the test case; the first field is a field in a plurality of data tables corresponding to the test case;
and the generating unit is used for generating test data based on a field constraint rule which is configured in advance or generated automatically according to the at least one first field.
Optionally, the second obtaining unit is specifically configured to:
determining a plurality of data tables corresponding to the test cases according to the test cases;
and acquiring at least one field in the plurality of data tables from a preset data dictionary according to the plurality of data tables.
Optionally, the apparatus further comprises:
the establishing unit is used for establishing a data dictionary;
and the storage unit is used for setting a plurality of fields and storing the set fields in the data dictionary.
Optionally, the generating unit is specifically configured to:
performing duplicate removal on the at least one acquired first field to obtain a first field after duplicate removal;
and generating test data based on a field constraint rule which is configured in advance or automatically generated according to the first field after the duplication removal.
Optionally, the apparatus further comprises:
and the filling unit is used for filling the generated test data into the plurality of data tables to obtain a data table of the number of the manufactured data.
In a third aspect, an apparatus is provided in an embodiment of the present application, where the apparatus includes a memory for storing instructions or codes and a processor for executing the instructions or codes to cause the apparatus to perform the method of any one of the foregoing first aspects.
In a fourth aspect, an embodiment of the present application provides a computer storage medium, where codes are stored, and when the codes are executed, an apparatus for executing the codes implements the method described in any one of the foregoing first aspects.
Compared with the prior art, the method has the following beneficial effects:
the method comprises the steps of obtaining a test case, obtaining at least one first field from a preset data dictionary according to the test case, wherein the first field is a field in a plurality of data tables corresponding to the test case, and generating test data according to the at least one first field and based on a field constraint rule which is configured in advance or generated automatically. According to the method and the device, the test data can be automatically generated based on the field constraint rule which is configured in advance or generated automatically according to the at least one first field obtained from the preset data dictionary, so that the problems that test data are manufactured manually in the prior art, but the task quantity of the number of the test data is large due to the fact that too many data tables of the test data need to be manufactured, a large amount of manpower is consumed and manpower resources are wasted due to the fact that the test data are manufactured manually are solved.
Drawings
To illustrate the technical solutions in the present embodiment or the prior art more clearly, the drawings needed to be used in the description of the embodiment or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a flowchart of a test data generation method provided in an embodiment of the present application;
FIG. 2 is a flow chart of another test data generation method provided in the embodiments of the present application;
fig. 3 is a schematic structural diagram of a test data generating apparatus according to an embodiment of the present disclosure.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without any creative effort belong to the protection scope of the present application.
It should be noted that, the test data generation method and apparatus provided by the present application are used in the field of data processing, and the foregoing is only an example, and does not limit the application field of the names of the method and apparatus provided by the present application.
With the development of social economy, more and more people choose to go to banks for business, and the transaction times of users are increased along with the business. Hundreds of data tables may be involved in each transaction, a bank develops its own system for collecting and supervising the data tables, and the data in the data tables needs to be tested to avoid problems due to the large number of data tables, but no data in the data tables needs to be created due to some uncertain factors.
At present, test data can be manufactured manually, but because a data table for manufacturing the test data is too many, the task amount for manufacturing the test data is large, and the test data manufactured manually consumes a large amount of manpower, which wastes manpower resources.
The inventor provides the technical scheme of the application through research, the test data can be automatically generated according to at least one first field acquired from a preset data dictionary based on a field constraint rule configured in advance or generated automatically, and therefore the problems that in the prior art, the test data are manufactured manually, but due to the fact that too many data tables of the test data need to be manufactured, the task quantity of the number of the test data needs to be large, a large amount of manpower is consumed for manufacturing the test data manually, and manpower resources are wasted are solved.
The method provided by the embodiment of the application can be executed by system software on terminal equipment, wherein the terminal equipment can be a computer, and the software can be system software on a controller with a computing function.
In order that those skilled in the art will better understand the disclosure, the following detailed description is given with reference to the accompanying drawings. The method provided by the embodiment of the present application is performed by the first device as an example.
Fig. 1 is a flowchart of a test data generation method provided in an embodiment of the present application, and as shown in fig. 1, the method includes:
s101: and acquiring a test case.
The first device acquires a test case. The test case, also called test case, generally refers to the description of the test task performed on a specific software product, and embodies the test scheme, method, technique and strategy. The contents of the test case may include test targets, test environments, input data, test steps, expected results, test scripts, etc., and form documents.
S102: and acquiring at least one first field from a preset data dictionary according to the test case.
After the first device obtains the test case, the first device may obtain at least one first field from a preset data dictionary according to the test case. The first field is a field in a plurality of data tables corresponding to the test case.
Explained further, the first device may determine a plurality of data tables corresponding to the test case according to the obtained test case, and then obtain at least one field in the plurality of data tables from a preset data dictionary according to the plurality of data tables.
Specifically, the data table can be simply understood as a two-dimensional data table (rows and columns have simple corresponding relations). Columns in the table may be referred to as fields, i.e., data sets having the same attributes, and each field may have a unique name, referred to as a field name. For example, in the table, if "gender" is stored in a column, the "gender" is a field name. A row in a table may be referred to as a record-it consists of several field values. For example, the table for recording each member may have fields of nickname, age, sex, email, etc., each member added to the table contains data of nickname, age, sex, email, etc., and these data of each member may constitute a record. The first device may retrieve fields in a plurality of data tables from the data dictionary.
S103: and generating test data according to the at least one first field based on a pre-configured or automatically generated field constraint rule.
After obtaining the at least one first field, the first device may generate test data based on a preconfigured or automatically generated field constraint rule according to the at least one first field.
The field constraint rule may be a constraint condition on a data type and a value range of the field. The constraint rules for the fields may include: randomly generating a data value, generating a fixed value, a non-NULL string, a non-NULL, including a fixed value, beginning with a fixed value, ending with a fixed value, not including a fixed value, not beginning with a fixed value, not ending with a fixed value, a specified location string equal to a fixed value, a specified location string not equal to a fixed value, a data value in a set, a data value not in a set, a data value in a data store, a data value not in a data store, a greater than or less than a condition, and the like.
To explain further:
the randomly generated data values may be test data generated freely according to a dictionary table system without setting constraints.
The fixed value, for example, the constraint condition is that the fixed value is abc, and the fixed field value abc is generated from the constraint condition.
And the non-empty character strings can be freely generated according to the dictionary table system without setting constraint conditions.
And if the data is not NULL, the non-NULL data can be freely generated according to the dictionary table system without setting constraint conditions.
The test data contains a fixed value, for example, a constraint condition is that the fixed value is abc, and the test data of abc is contained according to the dictionary table.
Starting with a fixed value, for example, the constraint condition is that the fixed value is abc, and the field value is a random character string containing the fixed value abc:
ending with a fixed value, for example, the constraint is that the fixed value is abc, and the fixed value is that the field value may be a random string whose tail is the fixed value abc.
Instead of beginning with a fixed value, for example, a random string whose fixed value abc is the constraint and whose field value is not the fixed value abc at the beginning is the constraint.
Instead of being tied to a fixed value, for example, a random character string whose constraint is that the fixed value is abc and the end of the field value is not abc is provided.
The position character is specified to be equal to a fixed value, for example, the constraint is that the fixed value is abc and the specified position in the field value is abc.
The character at the designated position is not equal to the fixed finger, for example, the constraint is that the fixed value is abc and the designated position in the field value is not abc.
Data values in a set, a field value is a specific value in the set, for example, a field value is a value in the set abcd.
The data value is not in a set and the field value is not a specific value in the set, e.g., the field value is not a value in the set abcd.
The data value is in the data store and the field value is a field obtained in the data store.
The data value is not in the data warehouse and the field value is data other than the data value stored in the data warehouse.
Greater than, the field value is greater than some data value, e.g., the field value is greater than 5, connected with a greater than sign (>).
Less, the field value is less than a certain data value, e.g., the field value is less than 5, connected with less than sign ().
The method comprises the steps of obtaining a test case, obtaining at least one first field from a preset data dictionary according to the test case, wherein the first field is a field in a plurality of data tables corresponding to the test case, and generating test data according to the at least one first field and based on a field constraint rule which is configured in advance or generated automatically. According to the method and the device, the test data can be automatically generated based on the field constraint rule which is configured in advance or generated automatically according to the at least one first field obtained from the preset data dictionary, so that the problem that in the prior art, the test data are manufactured manually is solved, but the task quantity of the test data is large due to the fact that a data table of the test data needs to be manufactured too much, a large amount of manpower needs to be consumed, and manpower resources are wasted due to the fact that the test data are manufactured manually is solved.
Fig. 2 is a flowchart of a test data generation method according to an embodiment of the present disclosure; as shown in fig. 2, the method includes:
s201: and establishing a data dictionary.
The first device establishes a data dictionary, wherein the data dictionary refers to defining and describing data items, data structures, data streams, data stores, processing logic and the like of data, and can be regarded as a database for storing defined fields.
S202: setting a plurality of fields through the data dictionary, and storing the set fields in the data dictionary.
The first device may set a plurality of fields through the data dictionary after establishing the data dictionary, and store the set plurality of fields in the data dictionary. So that the first device obtains the test cases to obtain fields in the plurality of data tables corresponding to the test cases from the data dictionary.
S203: and acquiring a test case.
S204: and acquiring at least one first field from a preset data dictionary according to the test case.
S205: and carrying out duplicate removal on the at least one acquired first field to obtain a first field after duplicate removal.
There may be a plurality of data tables corresponding to the test cases, and the first device may obtain a plurality of data tables, such as data table 1 and data table 2, each having corresponding fields and field numbers. For example, the field number in the data table 1 is 100, the field number in the data table 2 is also 100, the fields that can be acquired by the first device are deduplicated, and only one field with the same number may be reserved. The dictionary after deduplication is obtained. The purpose of this is that the data generated by the same field of multiple tables is the same, and multiple table association can be realized.
S206: and generating test data based on a field constraint rule which is configured in advance or generated automatically according to the first field after the duplication removal.
S207: and filling the generated test data into the plurality of data tables to obtain a number data table.
The first device may populate the plurality of data tables with the generated test data to obtain a manufactured data table. To test the data in the manufacture data table.
The foregoing is some specific implementation manners of the test data generation method provided in the embodiment of the present application, and based on this, the present application also provides a corresponding apparatus. In the following, a device provided in the embodiment of the present application will be described from the perspective of functional modularization, and the device and the above-described test data generation method may be referred to correspondingly.
Fig. 3 is a schematic structural diagram of a test data generating apparatus according to an embodiment of the present disclosure. As shown, the apparatus comprises:
a first obtaining unit 300 for obtaining a test case;
a second obtaining unit 310, configured to obtain at least one first field from a preset data dictionary according to the test case; the first field is a field in a plurality of data tables corresponding to the test case;
a generating unit 320, configured to generate test data based on a preconfigured or automatically generated field constraint rule according to the at least one first field.
Optionally, the second obtaining unit is specifically configured to:
determining a plurality of data tables corresponding to the test cases according to the test cases;
and acquiring at least one field in the plurality of data tables from a preset data dictionary according to the plurality of data tables.
Optionally, the apparatus further comprises:
the establishing unit is used for establishing a data dictionary;
and the storage unit is used for setting a plurality of fields through the data dictionary and storing the set fields in the data dictionary.
Optionally, the generating unit is specifically configured to:
removing the duplicate of the at least one acquired first field to obtain a first field after the duplicate removal;
and generating test data based on a field constraint rule which is configured in advance or generated automatically according to the first field after the duplication removal.
Optionally, the apparatus further comprises:
and the filling unit is used for filling the generated test data into the data tables to obtain a data table of the number of the data.
In the device, a first obtaining unit 300 obtains a test case, a second obtaining unit 310 obtains at least one first field from a preset data dictionary according to the test case, the first field is a field in a plurality of data tables corresponding to the test case, and a generating unit 320 generates test data according to the at least one first field and based on a field constraint rule configured in advance or generated automatically. According to the device, the test data can be automatically generated based on the field constraint rule which is configured in advance or generated automatically according to the at least one first field acquired from the preset data dictionary, so that the problem that in the prior art, the test data are manufactured manually, but the task quantity of the test data is large due to the fact that a data table of the test data needs to be manufactured too much, a large amount of manpower needs to be consumed and manpower resources are wasted due to the fact that the test data need to be manufactured manually is solved.
The embodiment of the application also provides corresponding equipment and a computer storage medium, which are used for realizing the scheme provided by the embodiment of the application.
Wherein the apparatus comprises a memory for storing instructions or code and a processor for executing the instructions or code to cause the apparatus to perform the method of any embodiment of the present application.
The computer storage medium has code stored therein, and when the code is executed, an apparatus for executing the code implements the vehicle load amount determining method according to any embodiment of the present application.
In the embodiments of the present application, the names "first" and "second" (if any) in the names "first" and "second" are used merely for name identification, and do not represent the sequential first and second.
As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that all or part of the steps in the above embodiment methods can be implemented by software plus a general hardware platform. Based on such understanding, the technical solution of the present application may be embodied in the form of a software product, and the computer software product may be stored in a storage medium, such as a read-only memory (ROM)/RAM, a magnetic disk, an optical disk, and the like, and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network communication device such as a router) to execute the vehicle load amount determining method according to the embodiments or some parts of the embodiments of the present application.
All the embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the apparatus embodiment, since it is substantially similar to the method embodiment, it is relatively simple to describe, and reference may be made to some descriptions of the method embodiment for relevant points. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
The above description is only an exemplary embodiment of the present application, and is not intended to limit the scope of the present application.

Claims (10)

1. A method of generating test data, comprising:
obtaining a test case;
acquiring at least one first field from a preset data dictionary according to the test case; the first fields are fields in a plurality of data tables corresponding to the test cases;
and generating test data according to the at least one first field based on a pre-configured or automatically generated field constraint rule.
2. The method of claim 1, wherein obtaining at least one first field from a predetermined data dictionary based on the test case comprises:
determining a plurality of data tables corresponding to the test cases according to the test cases;
and acquiring at least one field in the plurality of data tables from a preset data dictionary according to the plurality of data tables.
3. The method according to claim 1 or 2, characterized in that before the test case the method further comprises:
establishing a data dictionary;
setting a plurality of fields through the data dictionary, and storing the set plurality of fields in the data dictionary.
4. The method of claim 1, wherein generating test data based on preconfigured or automatically generated field constraint rules according to the at least one first field comprises:
performing duplicate removal on the at least one acquired first field to obtain a first field after duplicate removal;
and generating test data based on a field constraint rule which is configured in advance or automatically generated according to the first field after the duplication removal.
5. The method according to any one of claims 1-4, further comprising:
and filling the generated test data into the plurality of data tables to obtain a number data table.
6. A test data generation apparatus, comprising:
the first acquisition unit is used for acquiring the test case;
the second obtaining unit is used for obtaining at least one first field from a preset data dictionary according to the test case; the first fields are fields in a plurality of data tables corresponding to the test cases;
and the generating unit is used for generating test data based on a field constraint rule which is configured in advance or generated automatically according to the at least one first field.
7. The apparatus according to claim 6, wherein the second obtaining unit is specifically configured to:
determining a plurality of data tables corresponding to the test cases according to the test cases;
and acquiring at least one field in the plurality of data tables from a preset data dictionary according to the plurality of data tables.
8. The apparatus of claim 6 or 7, further comprising:
the establishing unit is used for establishing a data dictionary;
and the storage unit is used for setting a plurality of fields through the data dictionary and storing the set fields in the data dictionary.
9. The apparatus according to claim 6, wherein the generating unit is specifically configured to:
removing the duplicate of the at least one acquired first field to obtain a first field after the duplicate removal;
and generating test data based on a field constraint rule which is configured in advance or generated automatically according to the first field after the duplication removal.
10. The apparatus according to any one of claims 6-9, further comprising:
and the filling unit is used for filling the generated test data into the plurality of data tables to obtain a data table of the number of the manufactured data.
CN202210896135.5A 2022-07-27 2022-07-27 Test data generation method and device Pending CN115237783A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210896135.5A CN115237783A (en) 2022-07-27 2022-07-27 Test data generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210896135.5A CN115237783A (en) 2022-07-27 2022-07-27 Test data generation method and device

Publications (1)

Publication Number Publication Date
CN115237783A true CN115237783A (en) 2022-10-25

Family

ID=83677566

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210896135.5A Pending CN115237783A (en) 2022-07-27 2022-07-27 Test data generation method and device

Country Status (1)

Country Link
CN (1) CN115237783A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116303102A (en) * 2023-05-19 2023-06-23 建信金融科技有限责任公司 Test data generation method and device, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116303102A (en) * 2023-05-19 2023-06-23 建信金融科技有限责任公司 Test data generation method and device, electronic equipment and storage medium
CN116303102B (en) * 2023-05-19 2023-08-11 建信金融科技有限责任公司 Test data generation method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110019754B (en) Knowledge base building method, device and equipment
CN113886708A (en) Product recommendation method, device, equipment and storage medium based on user information
CN115237783A (en) Test data generation method and device
CN110275889B (en) Feature processing method and device suitable for machine learning
CN109492149A (en) Crawler task processing method and device
EP2219121A1 (en) Efficient computation of ontology affinity matrices
CN115544050A (en) Operation log recording method, device, equipment and storage medium
CN115186188A (en) Product recommendation method, device and equipment based on behavior analysis and storage medium
CN112860412A (en) Service data processing method and device, electronic equipment and storage medium
CN114936198A (en) Data migration method and device
CN113553425A (en) Data aggregation method, device, equipment and storage medium based on RPA and AI
CN112402955B (en) Game log recording method and system
CN114880430B (en) Name processing method and device
CN117235236B (en) Dialogue method, dialogue device, computer equipment and storage medium
CN110569362B (en) Ontology instantiation method and device
CN109712012B (en) Social network partitioning method, device, equipment and storage medium
CN111104529B (en) Index file control method and device and electronic equipment
CN116993358A (en) Service processing method, device, computer equipment, storage medium and program product
CN117370339A (en) Report blood edge relationship processing method and device, computer equipment and storage medium
CN116028448A (en) Identification code determining method, device, equipment and storage medium of electronic file
WO2017099806A1 (en) Hash suppression
CN115883503A (en) Message pushing method and device, computer equipment and storage medium
CN111581485A (en) Information distribution method and device
CN117708396A (en) Public opinion data processing method, public opinion data processing device, computer equipment and storage medium
CN116888590A (en) Entity heat generation method and device, storage medium and electronic equipment

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