CN115981996A - 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
CN115981996A
CN115981996A CN202211419069.9A CN202211419069A CN115981996A CN 115981996 A CN115981996 A CN 115981996A CN 202211419069 A CN202211419069 A CN 202211419069A CN 115981996 A CN115981996 A CN 115981996A
Authority
CN
China
Prior art keywords
target
attribute
attribute item
preset
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
CN202211419069.9A
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.)
Winning Health Technology Group Co Ltd
Original Assignee
Winning Health Technology Group 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 Winning Health Technology Group Co Ltd filed Critical Winning Health Technology Group Co Ltd
Priority to CN202211419069.9A priority Critical patent/CN115981996A/en
Publication of CN115981996A publication Critical patent/CN115981996A/en
Pending legal-status Critical Current

Links

Images

Abstract

The application provides a test data generation method, a test data generation device, test data generation equipment and a storage medium, and relates to the technical field of test data. The method comprises the steps of obtaining a preset test file, analyzing the preset test file to obtain all attribute items in the preset test file, determining a target attribute item from all attribute items, calling a target data generating function corresponding to the target attribute item to obtain target dynamic data corresponding to the target attribute item, replacing an attribute value of the target attribute item with the target dynamic data, and generating target test data, wherein the target dynamic data are dynamically generated data, so that the target test data generated by the same preset test file in each use are different, the diversity of the test data can be ensured, the test requirements can be met, and the reliability of the test result can be further improved.

Description

Test data generation method, device, equipment and storage medium
Technical Field
The present application relates to the field of test data technologies, and in particular, to a method, an apparatus, a device, and a storage medium for generating test data.
Background
The test data is data used by a tester to test a certain function, the tester needs to prepare the test data before running the test, and the test data needs to be used as input when running the test.
In the prior art, in software automated testing, test data capable of being directly tested is usually manually written, or test data is generated by automatically calling a test data generation algorithm, wherein the test data generated by calling the same test data generation algorithm every time are the same, but the test data with unchanged data content is used, so that the diversity of the test data is low, the reliability of a test result is low, and the test requirement cannot be met.
Disclosure of Invention
The present invention aims to provide a method, an apparatus, a device and a storage medium for generating test data, so as to solve the technical problem in the prior art that the diversity of the test data is low because the test data generated by calling the same test data generation algorithm each time are the same.
In order to achieve the above purpose, the embodiments of the present application adopt the following technical solutions:
in a first aspect, an embodiment of the present application provides a test data generation method, where the method includes:
acquiring a preset test file;
analyzing the preset test file to obtain all attribute items in the preset test file;
determining a target attribute item from all the attribute items;
calling a target data generating function corresponding to the target attribute item to obtain target dynamic data corresponding to the target attribute item;
and replacing the attribute value of the target attribute item with the target dynamic data to generate target test data.
Optionally, the determining a target attribute item from all the attribute items includes:
determining an attribute value as a target attribute item of a preset function type character string from all the attribute items;
the calling the target data generating function corresponding to the target attribute item to obtain the target dynamic data corresponding to the target attribute item includes:
analyzing the attribute value of the target attribute item to obtain the name of the target data generating function;
and calling the target data generating function according to the name of the target data generating function to obtain the target dynamic data.
Optionally, the determining, from all the attribute items, that the attribute value is the target attribute item of the preset function type string includes:
traversing all the attribute items, and determining whether the attribute values of the traversed attribute items are the preset function type character strings or not;
and if the attribute value of the traversed attribute item is the preset function type character string, determining the traversed attribute item as the target attribute item.
Optionally, the determining whether the attribute value of the traversed attribute item is the preset function type character string includes:
determining whether the attribute value of the traversed attribute item is a character string type;
and if the attribute value of the traversed attribute item is the character string type, judging whether the attribute value of the traversed attribute item is the preset function type character string or a non-function type character string.
Optionally, the method further comprises:
and if the attribute value of the traversed attribute item is not the character string type or the attribute value of the traversed attribute item is the non-function type character string, continuously traversing all the attribute items.
Optionally, the determining whether the attribute value of the traversed attribute item is the preset function type character string or a non-function type character string includes:
and judging whether the attribute value is the preset function type character string or not according to a preset regular expression.
Optionally, the calling the target data generating function according to the name of the target data generating function to obtain the target dynamic data corresponding to the target attribute item includes:
calling the target data generating function from a preset function library according to the name of the target data generating function to obtain the target dynamic data, wherein the preset function library stores: and each data generation function is a function corresponding to one dynamic data generation rule.
In a second aspect, an embodiment of the present application provides a test data generating apparatus, including:
the acquisition module is used for acquiring a preset test file;
the analysis module is used for analyzing the preset test file to obtain all attribute items in the preset test file;
a determining module, configured to determine a target attribute item from all the attribute items;
the calling module is used for calling a target data generating function corresponding to the target attribute item to obtain target dynamic data corresponding to the target attribute item;
and the replacing module is used for replacing the attribute value of the target attribute item with the target dynamic data to generate target test data.
In a third aspect, an embodiment of the present application provides a computer device, including: a storage medium and a processor, wherein the storage medium stores a computer program executable by the processor, and the processor implements the test data generating method of the first aspect when executing the computer program.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is read and executed, the method for processing test data generation data according to the first aspect is implemented.
Compared with the prior art, the method has the following beneficial effects:
according to the test data generation method, the test data generation device, the test data generation equipment and the storage medium, the preset test file is obtained, the preset test file is analyzed, all attribute items in the preset test file are obtained, the target attribute item is determined from all attribute items, the target data generation function corresponding to the target attribute item is called, the target dynamic data corresponding to the target attribute item is obtained, the attribute value of the target attribute item is replaced by the target dynamic data, and the target test data is generated.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a schematic flowchart of a test data generation method according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of a method for obtaining target dynamic data according to an embodiment of the present application;
fig. 3 is a schematic flowchart of a method for determining a target attribute item according to an embodiment of the present application;
fig. 4 is a schematic flowchart of a method for determining a type of an attribute value of a target attribute item according to an embodiment of the present application;
fig. 5 is a schematic diagram of a test data generating apparatus according to an embodiment of the present application;
fig. 6 is a schematic diagram of a computer device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, 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 some, but not all embodiments of the present application. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the features of the embodiments of the present invention may be combined with each other without conflict.
In the prior art, the test data generated by the same test data generation algorithm is static data, and the diversity of the test data is low, for example, JSON (JavaScript Object Notation) is a lightweight data exchange format, the test data in the JSON format is widely used in computer applications, the JSON test data is usually used as a static data, and the data content of the same JSON data is fixed and unchanged each time the same JSON data is used. Therefore, the present application provides a method, an apparatus, a device, and a storage medium for generating test data, so that the test data is dynamically generated, and exemplarily, the test data generated by the same JSON data in each use is different, which can ensure the diversity of the test data and meet the test requirements.
A test data generation method provided in the embodiments of the present application is explained below by using specific examples. Fig. 1 is a schematic flowchart of a test data generation method according to an embodiment of the present disclosure. As shown in fig. 1, the method includes:
s101, acquiring a preset test file.
Because the JSON-formatted test data is widely used in computer applications, the preset test file in the present application is specifically explained by taking a JSON-formatted data file as an example, where the preset test file is mainly used for dynamically generating the test data.
Optionally, the preset test file may also be a data file in an excel format, a txt format, or another format, and if the preset test file is not a data file in a JSON format, the preset test file may be converted into a data file in a JSON format.
S102, analyzing the preset test file to obtain all attribute items in the preset test file.
And analyzing the data in the preset test file according to the self syntax of the JSON and the corresponding analysis function to obtain all attribute items. Wherein each attribute item comprises: the attribute names and the attribute values are separated by colons, and each attribute item is separated by commas.
For example, one attribute item obtained by parsing may be: "name": "Zhang III", wherein name is attribute name, zhang III is attribute value; another attribute item obtained by parsing may be: "sex": "$ { getex () }", where sex is the attribute name and $ getex () } is the attribute value.
Alternatively, the attribute name may be understood as an additional interpretation of the variable name.
S103, determining a target attribute item from all the attribute items.
The attribute items may include a plurality of static attribute items, i.e. static data, and the test data generated at each use is the same, which may be "name" for example: "Zhang three"; the system can also comprise a plurality of dynamic attribute items, and can dynamically generate data, wherein the test data generated in each use is different.
In the embodiment of the application, the dynamic attribute item is the target attribute item, and then the corresponding test data can be dynamically generated according to the target attribute item.
And S104, calling a target data generating function corresponding to the target attribute item to obtain target dynamic data corresponding to the target attribute item.
Because each target attribute item can dynamically generate data, a target data generation function corresponding to the target attribute item needs to be determined first, and then target dynamic data corresponding to the target attribute item is obtained through calculation according to the target data generation function.
The target dynamic data obtained by each target data generating function is dynamically changed, that is, the target dynamic data obtained by each target data generating function in each use may be different.
Illustratively, if one of the target attribute items is: "six": "$ { getex () }", the target data generating function corresponding to the target attribute item may be a getex () function, the target dynamic data that can be obtained according to the target data generating function may be a male or a female, and the target dynamic data obtained in each use is randomly generated.
And S105, replacing the attribute value of the target attribute item with target dynamic data to generate target test data.
In JSON data, attribute names in target attribute items are generally fixed and do not need to be dynamically generated, and attribute values corresponding to the attribute names in the target attribute items need to be obtained through a target data generation function, so that the attribute values of all the target attribute items can be replaced by corresponding target dynamic data, and target test data can be generated.
The target test data does not have the target attribute item, and the target dynamic data is randomly generated, so that the target test data generated by the same preset test file every time is different data.
According to the test data generation method, the preset test file is obtained, all attribute items in the preset test file are obtained by analyzing the preset test file, the target attribute item is determined from all the attribute items, the target data generation function corresponding to the target attribute item is called, the target dynamic data corresponding to the target attribute item is obtained, the attribute value of the target attribute item is replaced by the target dynamic data, and the target test data is generated.
On the basis of the test data generation method shown in fig. 1, the embodiment of the present application further provides an implementation method for obtaining target dynamic data. Optionally, fig. 2 is a schematic flowchart of a method for obtaining target dynamic data according to an embodiment of the present application, and as shown in fig. 2, the method S103 determines a target attribute item from all attribute items, including:
and determining the attribute value as a target attribute item of the preset function type character string from all the attribute items.
Each attribute item includes: the attribute value is a target attribute item, and the attribute item whose attribute value is a preset function type string may be, for example, "$ { }" format or type string.
The method S104 calls the target data generating function corresponding to the target attribute item to obtain the target dynamic data corresponding to the target attribute item, and includes:
s201, analyzing the attribute value of the target attribute item to obtain the name of the target data generating function.
For example, if the attribute value of the target attribute item is "$ { getex () }", the name of the target data generation function obtained after the attribute value of the target is parsed is getex.
The method for analyzing may be to select data in { } to obtain getex (), and then continue to select data in (), that is, the name of the target data generating function, getex, or may also use other analyzing methods, which is not limited in this embodiment.
Optionally, a corresponding parsing method may be set according to the format setting information of the attribute value, so as to obtain the name of the target data generating function.
S202, calling the target data generating function according to the name of the target data generating function to obtain target dynamic data.
And finding the corresponding target data generating function according to the name of the target data generating function, and executing the target data generating function to obtain the target dynamic data.
For example, if the name of the target data generating function is getex, the corresponding target data generating function may be:
getSex(){
let options = [ "male", "female" ];
let index=Math.round(Math.random());
return options[index];
}
as can be seen, although the function is a random function, random () causes the function to output a random execution result at each call, where the random execution result is male or female, that is, the target dynamic data is male or female.
The name getsax of the target data generating function and the corresponding target data generating function getSex () are merely examples, and names of other target data generating functions and corresponding other target data generating functions may also be used, and are not particularly limited in the embodiment of the present application.
According to the method for obtaining the target dynamic data, the name of the target data generating function can be determined through the analyzed attribute value of the target attribute item, and then the corresponding target data generating function is called, so that the target dynamic data can be obtained, wherein the attribute value of each target attribute item is different, and the corresponding target data generating function is also different, so that more target dynamic data exist in the generated target test data, and the diversity of the target test data is further improved.
On the basis of the method for obtaining target dynamic data shown in fig. 2, the embodiment of the present application further provides an implementation method for obtaining target dynamic data. Optionally, fig. 3 is a schematic flowchart of a method for determining a target attribute item according to an embodiment of the present application, as shown in fig. 3, in the embodiment, determining a target attribute item whose attribute value is a preset function type string from all attribute items includes:
s301, traversing all attribute items, and determining whether the attribute values of the traversed attribute items are preset function type character strings.
And traversing the attribute items in the preset test file, and determining whether the attribute values of the traversed attribute items are the preset function type character strings or not in the traversing process.
For example, the preset function type string may be in a format of "$ { }" or a type string, if the format of the attribute value in the attribute item is the preset function type string, it is determined that the attribute value is the preset function type string, otherwise, the attribute value is not the preset function type string.
And if the attribute value of the traversed attribute item is not the preset function type character string, continuing to traverse the attribute item and determining the preset function type character string for the attribute value of the attribute item.
Optionally, the preset function type character string may also be a character string in another format or type, and is not particularly limited in this embodiment of the application.
S302, if the attribute value of the traversed attribute item is a preset function type character string, determining the traversed attribute item as a target attribute item.
In the embodiment of the application, after an attribute item is obtained by traversal, a preset function type character string is judged for an attribute value of the attribute item, if the preset function type character string is obtained, the attribute item is a target attribute item, a target data generating function corresponding to the target attribute item is called, target dynamic data corresponding to the target attribute item is obtained, and the attribute value of the target attribute item is replaced by the target dynamic data.
And after replacement, continuously traversing the next attribute item until the attribute values of all the attribute items in the preset test file are not the preset function type character strings, and obtaining target test data.
According to the method for determining the target attribute item, provided by the embodiment of the application, all attribute items are traversed, whether the attribute value of the traversed attribute item is the preset function type character string or not is determined, if the attribute value of the traversed attribute item is the preset function type character string, the traversed attribute item is determined to be the target attribute item, data replacement of the attribute value of the target attribute item is carried out until the attribute values of all the attribute items in the preset test file are not the preset function type character string, and dynamic target test data can be obtained.
On the basis of the method for determining the target attribute item shown in fig. 3, an embodiment of the present application further provides an implementation method for determining an attribute value of the target attribute item. Optionally, fig. 4 is a schematic flowchart of a method for determining a type of an attribute value of a target attribute item according to an embodiment of the present application, and as shown in fig. 4, the method S301 determines whether an attribute value of a traversed attribute item is a preset function type string, including:
s401, determining whether the attribute value of the traversed attribute item is a character string type.
The type of the attribute value of the traversed attribute item may be determined by a type function, for example, the type function may be a typeof function, and of course, the type function may also be a function determined by other types, and is not particularly limited in the embodiment of the present application.
If the type of the attribute value of the traversed attribute item is determined to be the character string type, continuing to judge, and if the type of the attribute value of the traversed attribute item is determined not to be the character string type, continuing to traverse all the attribute items.
In this embodiment of the application, the type of the attribute value of the attribute item of the preset test file in the JSON format may be a character string type, or a JSON object type, and if it is determined that the traversed attribute value of the attribute item is the JSON object type, the JSON object is a nested JSON object, and the content included in the JSON object includes the attribute value of the attribute item, therefore, all the attribute items in the JSON object need to be traversed recursively.
S402, if the attribute value of the traversed attribute item is the character string type, judging whether the attribute value of the traversed attribute item is a preset function type character string or a non-function type character string.
If the attribute value of the traversed attribute item is the character string type, continuously and further judging whether the character string type of the attribute value of the traversed attribute item is a preset function type, and if the character string type is the preset function type, determining the attribute item as a target attribute item.
If the attribute value of the traversed attribute item is a non-function type character string, the attribute value is represented as static data, and data replacement is not needed.
The method for judging the type of the attribute value of the target attribute item, provided by the embodiment of the application, determines whether the traversed attribute value of the traversed attribute item is a character string type, and if the traversed attribute value of the traversed attribute item is the character string type, judges whether the traversed attribute value of the traversed attribute item is a preset function type character string or a non-function type character string, and if the traversed attribute value of the traversed attribute item is the preset function type character string, determines that the attribute item is the target attribute item, so that the attribute value of the target attribute item can be replaced by target dynamic data.
On the basis of the method for judging the type of the attribute value of the target attribute item shown in fig. 4, the embodiment of the present application further provides another method for realizing the judgment of the type of the attribute value of the target attribute item. Optionally, the method S402 of determining whether the attribute value of the traversed attribute item is a preset function type string or a non-function type string includes:
and judging whether the attribute value is a preset function type character string or not according to the preset regular expression.
Where a regular expression uses a single string to describe, match, a series of strings matching a certain syntactic rule (a preset function type string), it can be used to retrieve strings that conform to a certain rule (a preset function type string).
In the embodiment of the application, the corresponding preset regular expression can be set according to the preset function type, and then whether the attribute value is the preset function type character string or not can be judged through the regular expression.
For example, when the preset function type string is "$ { }", a corresponding preset regular expression may be set according to each character in the preset function type string and a position relationship between the characters.
According to the method for judging the type of the attribute value of the target attribute item, whether the attribute value is a preset function type character string or not is judged according to the preset regular expression, and then whether the attribute item is the target attribute item or not can be determined.
On the basis of the method for obtaining target dynamic data shown in fig. 2, an embodiment of the present application further provides an implementation method for obtaining target dynamic data. Optionally, the method S202, calling the target data generating function according to the name of the target data generating function, and obtaining the target dynamic data, includes:
and calling the target data generating function from a preset function library according to the name of the target data generating function to obtain target dynamic data.
The preset function library is stored with: and each data generation function is a function corresponding to one dynamic data generation rule.
In this embodiment of the present application, a plurality of custom functions are defined in the preset function library, and the plurality of custom functions may also be referred to as a plurality of data generating functions, where a name of each data generating function may correspond to one data generating function, that is, a name of a target data generating function may correspond to one target data generating function.
In order to ensure that each data generation function can obtain dynamic data, all data generation functions in the preset function library include dynamic data generation rules. For example, the dynamic data generation rule may be a random function, and of course, other dynamic data generation rules may also be used, and are not specifically limited in the embodiment of the present application.
Optionally, when the preset test file is in the JSON format, the custom function may be written using Javascript, and a data generation function with any function is implemented by Javascript. Illustratively, the function of the above-described target data generation function getSex () is to randomly generate gender data.
According to the method for obtaining the target dynamic data, the target data generating function is called from the preset function library according to the name of the target data generating function, so that the target dynamic data is obtained, wherein the preset function library stores: each data generation function is a function corresponding to one dynamic data generation rule, and each data generation function can output target dynamic data with randomness through the dynamic data generation rule, so that the diversity of target test data is high.
The following describes a test data generating apparatus, a device, and a storage medium for executing the test data generating apparatus, device, and storage medium provided by the present application, and specific implementation procedures and technical effects thereof are referred to above, and are not described again below.
Fig. 5 is a schematic diagram of a test data generating apparatus according to an embodiment of the present application, and as shown in fig. 5, the test data generating apparatus includes:
an obtaining module 501 is configured to obtain a preset test file.
The parsing module 502 is configured to parse the preset test file to obtain all attribute items in the preset test file.
A determining module 503, configured to determine a target attribute item from all attribute items.
And the calling module 504 is configured to call a target data generating function corresponding to the target attribute item, so as to obtain target dynamic data corresponding to the target attribute item.
And a replacing module 505, configured to replace the attribute value of the target attribute item with target dynamic data, so as to generate target test data.
Optionally, the determining module 503 is specifically configured to determine, from all the attribute items, a target attribute item whose attribute value is a preset function type string; calling a target data generating function corresponding to the target attribute item to obtain target dynamic data corresponding to the target attribute item, wherein the method comprises the following steps: analyzing the attribute value of the target attribute item to obtain the name of a target data generating function; and calling the target data generating function according to the name of the target data generating function to obtain target dynamic data.
Optionally, the determining module 503 is specifically configured to traverse all the attribute items, and determine whether an attribute value of the traversed attribute item is a preset function type character string; and if the attribute value of the traversed attribute item is the preset function type character string, determining the traversed attribute item as a target attribute item.
Optionally, the determining module 503 is specifically configured to determine whether the attribute value of the traversed attribute item is a character string type; and if the attribute value of the traversed attribute item is the character string type, judging whether the attribute value of the traversed attribute item is a preset function type character string or a non-function type character string.
Optionally, the determining module 503 is further configured to continue traversing all the attribute items if the attribute value of the traversed attribute item is not a string type, or the attribute value of the traversed attribute item is a non-function type string.
Optionally, the determining module 503 is specifically configured to determine, according to the preset regular expression, whether the attribute value is a preset function type character string.
Optionally, the calling module 504 is specifically configured to call the target data generating function from a preset function library according to the name of the target data generating function, so as to obtain the target dynamic data, where: and each data generation function is a function corresponding to one dynamic data generation rule.
These above modules may be one or more integrated circuits configured to implement the above methods, such as: one or more Application Specific Integrated Circuits (ASICs), or one or more microprocessors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs), among others. For another example, when one of the above modules is implemented in the form of a Processing element scheduler code, the Processing element may be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. As another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
Fig. 6 is a schematic diagram of a computer device provided in an embodiment of the present application, where the computer device may be a computing device with a computing processing function.
The computer device includes: a processor 601, a storage medium 602, a bus 603. The processor 601 and the storage medium 602 are connected by a bus 603.
The storage medium 602 is used to store a program, and the processor 601 calls the program stored in the storage medium 602 to execute the above-mentioned method embodiments. The specific implementation and technical effects are similar, and are not described herein again.
Optionally, the invention also provides a program product, for example a computer-readable storage medium, comprising a program which, when being executed by a processor, is adapted to carry out the above-mentioned method embodiments.
In the several embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one type of logical functional division, and other divisions may be realized in practice, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (in english: processor) to execute some steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: a U disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A method for generating test data, comprising:
acquiring a preset test file;
analyzing the preset test file to obtain all attribute items in the preset test file;
determining a target attribute item from all the attribute items;
calling a target data generating function corresponding to the target attribute item to obtain target dynamic data corresponding to the target attribute item;
and replacing the attribute value of the target attribute item with the target dynamic data to generate target test data.
2. The method according to claim 1, wherein the determining a target attribute item from the all attribute items comprises:
determining an attribute value as a target attribute item of a preset function type character string from all attribute items;
the calling the target data generating function corresponding to the target attribute item to obtain the target dynamic data corresponding to the target attribute item includes:
analyzing the attribute value of the target attribute item to obtain the name of the target data generating function;
and calling the target data generating function according to the name of the target data generating function to obtain the target dynamic data.
3. The method according to claim 2, wherein the determining, from the all attribute items, an attribute value as a target attribute item of a preset function type string includes:
traversing all the attribute items, and determining whether the attribute values of the traversed attribute items are the preset function type character strings or not;
and if the attribute value of the traversed attribute item is the preset function type character string, determining the traversed attribute item as the target attribute item.
4. The method according to claim 3, wherein the determining whether the attribute value of the traversed attribute item is the preset function type string comprises:
determining whether the attribute value of the traversed attribute item is a character string type;
and if the attribute value of the traversed attribute item is the character string type, judging whether the attribute value of the traversed attribute item is the preset function type character string or a non-function type character string.
5. The method of test data generation according to claim 4, further comprising:
and if the attribute value of the traversed attribute item is not the character string type or the attribute value of the traversed attribute item is the non-function type character string, continuously traversing all the attribute items.
6. The method according to claim 4, wherein the determining whether the attribute value of the traversed attribute item is the preset function type string or a non-function type string includes:
and judging whether the attribute value is the preset function type character string or not according to a preset regular expression.
7. The method according to claim 2, wherein the calling the target data generating function according to the name of the target data generating function to obtain the target dynamic data corresponding to the target attribute item includes:
calling the target data generating function from a preset function library according to the name of the target data generating function to obtain the target dynamic data, wherein the preset function library stores: and each data generation function is a function corresponding to one dynamic data generation rule.
8. A test data generating apparatus, comprising:
the acquisition module is used for acquiring a preset test file;
the analysis module is used for analyzing the preset test file to obtain all attribute items in the preset test file;
a determining module, configured to determine a target attribute item from all the attribute items;
the calling module is used for calling a target data generating function corresponding to the target attribute item to obtain target dynamic data corresponding to the target attribute item;
and the replacing module is used for replacing the attribute value of the target attribute item with the target dynamic data to generate target test data.
9. A computer device, comprising: a storage medium storing a computer program executable by a processor, the processor implementing the test data generation method of any one of claims 1 to 7 when executing the computer program, and a processor.
10. A computer-readable storage medium, having stored thereon a computer program which, when read and executed, implements the test data generation method of any one of claims 1 to 7.
CN202211419069.9A 2022-11-14 2022-11-14 Test data generation method, device, equipment and storage medium Pending CN115981996A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211419069.9A CN115981996A (en) 2022-11-14 2022-11-14 Test data generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211419069.9A CN115981996A (en) 2022-11-14 2022-11-14 Test data generation method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115981996A true CN115981996A (en) 2023-04-18

Family

ID=85972752

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211419069.9A Pending CN115981996A (en) 2022-11-14 2022-11-14 Test data generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115981996A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116610591A (en) * 2023-07-20 2023-08-18 金篆信科有限责任公司 Method, device, system and medium for generating test data and call statement

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116610591A (en) * 2023-07-20 2023-08-18 金篆信科有限责任公司 Method, device, system and medium for generating test data and call statement
CN116610591B (en) * 2023-07-20 2023-09-12 金篆信科有限责任公司 Method, device, system and medium for generating test data and call statement

Similar Documents

Publication Publication Date Title
US10282197B2 (en) Open application lifecycle management framework
JP4878624B2 (en) Document processing apparatus and document processing method
CN112800095B (en) Data processing method, device, equipment and storage medium
CN101751333A (en) Method, computer program and computer system for assisting in analyzing program
CN107015839B (en) Method and device for realizing front-end event agent
CN111160021A (en) Log template extraction method and device
CN110019116B (en) Data tracing method, device, data processing equipment and computer storage medium
CN112148619A (en) Test case suite optimization processing method and device, electronic equipment and storage medium
CN110795697A (en) Logic expression obtaining method and device, storage medium and electronic device
CN112035480A (en) Data table management method, device, equipment and storage medium
CN115981996A (en) Test data generation method, device, equipment and storage medium
CN115238138A (en) Graph data query method and device
CN110716912B (en) SQL performance detection method and server
CN112069052B (en) Abnormal object detection method, device, equipment and storage medium
CN115421831A (en) Method, device, equipment and storage medium for generating calling relation of activity component
CN112417020B (en) Service expansion realization method, device, computer equipment and storage medium
CN112817922B (en) Log dynamic printing method and device, computer equipment and storage medium
CN113448985A (en) API (application program interface) interface generation method, calling method and device and electronic equipment
CN114417883A (en) Data processing method, device and equipment
US11630662B2 (en) Software analysis device, software analysis method, and software analysis program
CN112214497A (en) Label processing method and device and computer system
CN112307050B (en) Identification method and device for repeated correlation calculation and computer system
US20230053109A1 (en) Generating data regulation compliant data from application interface data
CN113778904B (en) Multi-terminal system testing method and device based on integrated test case
CN110008238B (en) NLJ improved table connection method and data query method based on the improved method

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