CN111427759A - Test data generation method and device, electronic equipment and computer readable medium - Google Patents
Test data generation method and device, electronic equipment and computer readable medium Download PDFInfo
- Publication number
- CN111427759A CN111427759A CN201910018279.9A CN201910018279A CN111427759A CN 111427759 A CN111427759 A CN 111427759A CN 201910018279 A CN201910018279 A CN 201910018279A CN 111427759 A CN111427759 A CN 111427759A
- Authority
- CN
- China
- Prior art keywords
- test data
- attribute
- attribute value
- value list
- data set
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The present disclosure provides a test data generation method, a device, an electronic device and a computer readable medium, wherein the method comprises the following steps: classifying the original data according to attributes to obtain an attribute value list; sorting each attribute item in the attribute value list; and processing the attribute value list by applying a preset strategy to generate a test data set. By adopting the test data generation method provided by the disclosure, a large amount of test data can be automatically, quickly and conveniently generated so as to facilitate software testing of testers.
Description
Technical Field
The present disclosure relates to the field of computers and internet, and in particular, to a method and an apparatus for generating test data, an electronic device, and a computer-readable medium.
Background
With the progress of computer science and technology and the rapid development of the software industry, the software testing work is more and more concerned by people. In a software test case, a tester typically confirms whether the logic of the software is performing as expected by modifying the input test data of the software. In actual work, the generation and maintenance of test data are very important in software testing, the work is just tedious and repeated and is very easy to make mistakes, and undoubtedly, it is meaningful to find a universal data generation method.
In many test data preparation processes, data creators perform grope creation of test data based on some basic documents or basic knowledge of the business. Some simple data creating work with small data volume is easy for manual operation, but when a large amount of test data is needed, how to let a program or a tool automatically generate a desired test data set becomes one of the problems to be solved urgently in the current software test.
Disclosure of Invention
In view of this, the present disclosure provides a test data generation method and apparatus, an electronic device, and a computer readable medium, which can quickly create or maintain test data, improve software testing efficiency to find a defect of a software program in time, and help the defect to be remedied.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows, or in part will be obvious from the description, or may be learned by practice of the disclosure.
According to an aspect of an embodiment of the present disclosure, a data generating method is provided, where the method includes: classifying the original data according to attributes to obtain an attribute value list; sorting each attribute item in the attribute value list; and processing the attribute value list by applying a preset strategy to generate a test data set.
In an exemplary embodiment of the present disclosure, the test data set includes any one or more of a first test data set, a second test data set, and a third test data set; and processing the attribute value list by applying different preset strategies to generate different test data sets.
In an exemplary embodiment of the present disclosure, if the test data set is a first test data set; processing the attribute value list by applying a preset strategy to generate a test data set, wherein the method comprises the following steps: respectively extracting the kth attribute value in each attribute item to generate the kth test data in the first test data set; k is a positive integer greater than or equal to 1 and less than or equal to N, and N is the maximum value of the attribute length in the attribute value list.
In an exemplary embodiment of the present disclosure, the data generating method further includes: if the length M of the attribute value of at least one attribute item is smaller than N, circularly and sequentially extracting the 1 st to M th attribute values from the at least one attribute item to be filled as the M +1 th to N th attribute values of the at least one attribute item.
In an exemplary embodiment of the present disclosure, if the test data set is the second test data set; processing the attribute value list by applying a preset strategy to generate a test data set, wherein the method comprises the following steps: and processing the sorted attribute value list by using an orthogonal algorithm to generate the second test data set.
In an exemplary embodiment of the present disclosure, if the test data set is the third test data set; processing the attribute value list by applying a preset strategy to generate a test data set, wherein the method comprises the following steps: processing the sorted attribute value list by using an orthogonal algorithm; generating noise values consistent with at least part of attribute types in the attribute value list; and adding the generated noise value to the attribute value list after orthogonal processing to generate the third test data set.
In an exemplary embodiment of the present disclosure, the generating noise values of at least some of the attributes in the attribute value list includes: acquiring a noise data set; and matching the types of the noise values in the noise data set according to the types of at least part of attributes of the attribute value list so as to obtain the noise values consistent with the types of at least part of attributes of the attribute value list.
In an exemplary embodiment of the present disclosure, the data generating method further includes: and carrying out data reduction on the classified attribute value list.
In an exemplary embodiment of the present disclosure, the data reduction includes any one or more of deduplication, dead-point removal, and error correction processing for each attribute value list.
According to a second aspect of the embodiments of the present disclosure, there is provided a test data generation apparatus, including: the attribute classification module is configured to classify the original data according to attributes to obtain an attribute value list; an attribute ordering module configured to order each of the attribute value lists; and the test data generation module is configured to apply a preset strategy to process the attribute value list to generate a test data set.
According to a third aspect of the embodiments of the present disclosure, an electronic device is provided, which includes: one or more processors; a storage device for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement the test data generation method of any one of the above.
According to a fourth aspect of the embodiments of the present disclosure, a computer-readable medium is proposed, on which a computer program is stored, wherein the program, when executed by a processor, implements the test data generation method according to any one of the above.
According to the test data generation method and device, the electronic device and the computer readable medium provided by some embodiments of the present disclosure, a plurality of test data sets and test data sets are generated quickly and conveniently by classifying and sorting raw data and using a plurality of different strategies, respectively, so as to help a tester complete a test.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure. The drawings described below are merely some embodiments of the present disclosure, and other drawings may be derived from those drawings by those of ordinary skill in the art without inventive effort.
Fig. 1 is a schematic diagram showing an exemplary system architecture to which a test data generation method or a test data generation apparatus according to an embodiment of the present invention can be applied.
FIG. 2 is a flow chart illustrating a method of test data generation according to an exemplary embodiment.
FIG. 3 is a flow chart illustrating a method of test data generation according to another exemplary embodiment.
FIG. 4 is a flow chart illustrating a method of test data generation according to another exemplary embodiment.
FIG. 5 is a flow chart illustrating a method of test data generation according to another exemplary embodiment.
FIG. 6 is a flow chart illustrating a method of test data generation according to another exemplary embodiment.
Fig. 7 is a flow chart illustrating a noise data generation method according to another exemplary embodiment.
FIG. 8 is a block diagram illustrating a test data generation apparatus according to an example embodiment.
Fig. 9 is a schematic structural diagram illustrating a computer system applied to a test data generating apparatus according to an exemplary embodiment.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art. The same reference numerals denote the same or similar parts in the drawings, and thus, a repetitive description thereof will be omitted.
The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to provide a thorough understanding of embodiments of the invention. One skilled in the relevant art will recognize, however, that the invention may be practiced without one or more of the specific details, or with other methods, components, devices, steps, and so forth. In other instances, well-known methods, devices, implementations or operations have not been shown or described in detail to avoid obscuring aspects of the invention.
The drawings are merely schematic illustrations of the present invention, in which the same reference numerals denote the same or similar parts, and thus, a repetitive description thereof will be omitted. Some of the block diagrams shown in the figures do not necessarily correspond to physically or logically separate entities. These functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor devices and/or microcontroller devices.
The flow charts shown in the drawings are merely illustrative and do not necessarily include all of the contents and steps, nor do they necessarily have to be performed in the order described. For example, some steps may be decomposed, and some steps may be combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
In this specification, the terms "a", "an", "the", "said" and "at least one" are used to indicate the presence of one or more elements/components/etc.; the terms "comprising," "including," and "having" are intended to be inclusive and mean that there may be additional elements/components/etc. other than the listed elements/components/etc.; the terms "first," "second," and "third," etc. are used merely as labels, and are not limiting on the number of their objects.
The following detailed description of exemplary embodiments of the invention refers to the accompanying drawings.
Fig. 1 is a schematic diagram showing an exemplary system architecture to which a test data generation method or a test data generation apparatus according to an embodiment of the present invention can be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a server that provides various services, such as a background management server that provides support for devices operated by users using the terminal apparatuses 101, 102, 103. The background management server can analyze and process the received data such as the request and feed back the processing result to the terminal equipment.
The server 105 may, for example, sort the raw data by attribute, obtaining a list of attribute values; the server 105 may, for example, order each attribute item in the attribute value list; the server 105 may process the list of attribute values, for example, by applying a preset policy, and generate a test data set.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative, and the server 105 may be a physical server or may be composed of a plurality of servers, and there may be any number of terminal devices, networks, and servers according to implementation needs. It should be noted that the test data generation method provided in the embodiment of the present application is generally executed by the server 105, and accordingly, the test data generation apparatus is generally disposed in the server 105.
FIG. 2 is a flow chart illustrating a method of test data generation according to an exemplary embodiment.
Referring to fig. 2, the test data generation method may include the following steps.
Step S201, classifying the original data according to the attributes, and obtaining an attribute value list.
In some embodiments, the raw data refers to de-sensitized real data extracted from the production environment or online data. Data desensitization refers to data deformation of some sensitive information through desensitization rules, and reliable protection of sensitive private data is achieved. For example, in the case of customer security data or some business sensitive data, data desensitization is required to reconstruct real data and provide test use without violating system rules, such as personal information like identification number, mobile phone number, card number, customer number, and the like.
But the raw data cannot meet the data requirements of the test software. During software testing, correct data needs to be input to detect whether the output result of the program is correct or not, and error data needs to be input to detect the difference between the output result of the program and the expected output result, so as to judge whether the software can automatically remind a fault, automatically recover or ignore the fault to continue running or not. The input data types of the error may include: wrong data type, values outside the defined domain, wrong operation sequence, abnormal interruption of communication, abnormal shutdown of a function, load exceeding a limit, etc.
In the embodiment of the present invention, in order to test the fault tolerance and robustness of the program in consideration of the above abnormal conditions, after the original data after desensitization is taken, the data needs to be extracted first, which may include: the method comprises the steps of classifying original data according to attributes to obtain an attribute value list, and respectively reducing the classified attribute value list according to the attributes. Wherein the data reduction includes any one or more of deduplication, dead-point removal, error correction, and the like for the attribute value list. The deduplication processing refers to deleting redundant data in data, the bad point removing processing refers to deleting data with obvious errors, and the error correction processing refers to automatically correcting some error data in a data list.
For example, raw data of a customer order is obtained from an online database, and the raw data is reduced and classified according to attributes to generate an attribute value list as shown in table 1, wherein the attributes include: name, age, nationality, and order amount.
TABLE 1
Serial number | Name (I) | Age (age) | Nationality book | Amount of order |
1 | Zhang three | 20 | China (China) | 550 |
2 | Zhang three | 20 | China (China) | 360 |
3 | Li four | 30 | United states of |
800 |
And respectively carrying out data reduction on each attribute item in each attribute value list to obtain a table 2.
TABLE 2
Name (I) | Age (age) | Nationality book | Amount of order |
Zhang three | 20 | China (China) | 550 |
Li four | 30 | United states of America | 360 |
800 |
Step S202, sorting each attribute item in the attribute value list.
In the embodiment of the present invention, after performing data reduction and classification on the desensitized original data attribute items to generate an attribute value list, the attribute values in each attribute item in the attribute value list need to be ordered according to a certain rule, for example: the numeric data is sorted in ascending order (the present disclosure is not limited thereto, and for example, in other embodiments, the numeric data may be sorted in descending order according to an attribute value in an attribute item), and the alphabetic data is sorted in alphabetic initials. For example, on the basis of table 2, sorting the numbers in the reduced attribute value list in ascending order and sorting the letters in ascending order of the initials of pinyin may result in the data shown in table 3.
TABLE 3
Name (I) | Age (age) | Nationality book | Amount of order |
Li four | 20 | United states of America | 360 |
Zhang three | 30 | China (China) | 550 |
800 |
Step S203, processing the attribute value list by applying a preset strategy to generate a test data set.
In the embodiment of the present invention, after the sorted attribute value list is obtained, a preset strategy may be adopted to process the attribute value list, so as to obtain a test data set. The preset strategies may include a first preset strategy, a second preset strategy, and a third preset strategy, the test data set may include a first test data set, a second test data set, and a third test data set, and the first test data set, the second test data set, and the third test data set may be generated by using the first preset strategy, the second preset strategy, and the third preset strategy respectively.
In the embodiment of the present invention, the program test performed by generating the test data set by using the preset policy may include the following advantages: 1. the test data set is generated quickly and conveniently so that a tester can test conveniently. 2. The generated test data set can not only meet the basic requirements of the program test, but also ensure the efficiency of the program test. 3. The test data set may incorporate noise data to test the robustness and fault tolerance of the program.
FIG. 3 is a flow chart illustrating a method of test data generation according to another exemplary embodiment.
Referring to fig. 3, the method for generating test data according to the embodiment of the present invention may include steps S301, S302, and S303, where steps S301 and S302 may refer to steps S201 and S202 in fig. 2, and are not described herein again. Step S303, processing the attribute value list by applying a first preset policy, and generating first test data. In an embodiment of the present invention, the first preset policy may include: respectively extracting the kth attribute value in each attribute to generate the kth test data in the first test data set; k is a positive integer greater than or equal to 1 and less than or equal to N, and N is the maximum value of the attribute length in the attribute value list.
In the embodiment of the present invention, if the length M of the attribute value in at least one attribute item is smaller than N, the 1 st to M th attribute values are cyclically and sequentially extracted from the at least one attribute item and filled as the M +1 th to N th attribute values of the at least one attribute item.
When M is smaller than N/2, circularly extracting attribute values in the at least one attribute item in sequence and filling the attribute values into the at least one attribute item until the length of the at least one attribute item is equal to N;
when M is equal to N/2, sequentially filling the 1 st to Mth attribute values in the at least one attribute item to the M +1 th to Nth attribute values of the at least one attribute item;
and when M is larger than N/2, sequentially filling the 1 st to the N-M attribute values of the at least one attribute item to the M +1 th to the N-th attribute values of the at least one attribute item.
For example, when M is equal to 10 and N is equal to 26, sequentially extracting the 1 st to 10 th attribute values in the at least one attribute item and sequentially filling the 1 st to 20 th attribute values in the at least one attribute item, and then circularly extracting the 1 st to 6 th attribute values in the at least one attribute item and sequentially filling the 21 st to 26 th attribute values in the at least one attribute item again until the length of the at least one attribute item is equal to 26.
When M is equal to 13 and N is equal to 26, sequentially extracting the 1 st to 13 th attribute values in the at least one attribute item and sequentially filling the 14 th to 26 th attribute values in the at least one attribute item until the length of the at least one attribute item is equal to 26.
When M is equal to 15 and N is equal to 26, sequentially extracting the 1 st to 11 th attribute values in the at least one attribute item and sequentially filling the 16 th to 26 th attribute values in the at least one attribute item until the length of the at least one attribute item is equal to 26.
Alternatively, when the test data set is generated as the first test data set, the method shown in the embodiment of fig. 4 may also be adopted. FIG. 4 is a flow chart illustrating a method of test data generation according to another exemplary embodiment.
In the present embodiment, A represents an attribute value list, ApRepresenting each attribute item in the attribute value list, the subscript p is greater than 1 and less than N, wherein N refers to the number of attribute items in the attribute value list, N is the maximum value of the attribute length of each attribute item in the attribute value list, i and j are position variables representing the positions of attribute values in the attribute items, i and j are only two of the position variables, in the embodiment, N position variables with completely same functions and steps exist, and the description of the position variables is omitted for simplicity, Ap[j]Meaning the jth attribute value in the pth attribute item in the attribute value list. .
In this embodiment, the attribute value list includes a plurality of attribute items, now denoted by ApRepresenting any one of the attribute items in the attribute value list.
Referring to fig. 4, the test data generation method may include the following steps.
Step S401, classifies the original data according to attributes, and acquires an attribute value list a.
Step S402, for each attribute item A in the attribute value listpAfter sorting, obtain Ap’。
Wherein, the steps S401 and S402 are completely consistent with the steps S201 and S202 in fig. 2, and are not described herein again.
In step S403, an initialization operation is performed. Let the count variable k equal 0 and the n position variables all be 0, e.g., i equal 0 and j equal 0.
After initializing each variable, the attribute values need to be extracted from each attribute item to compose test data. Specifically, now Ap' for example, the extraction process of the attribute value is explained. Step S404, judging whether the size of j +1 is equal to the attribute item Ap' length. If j +1 is equal to the attribute item ApLength of' and execution stepsStep S405, let j equal 0; if the size of j +1 is not equal to the attribute item Ap' Length, step S406 is performed, i.e. the attribute item A is fetchedp' the j-th attribute value Ap’[j]。
Similarly, steps S404 to S406 are also executed for the other attribute items in the attribute value list, and the attribute value at the corresponding position is extracted.
Step S407 is executed when the corresponding attribute values of all the attribute items are taken out. Step S407, extracting n attribute values A from n attribute items1’[i]~Ap’[j]And combining the k test data.
In step S408, it is determined whether k is equal to N. If k is not equal to N, go to step S409. In step S409, count variable k and other k +1, n attribute item position variables are all sequentially incremented by 1, for example, i equals i +1, and j equals j + 1. Then, steps S404 to S09 are repeatedly executed until k is determined to be equal to N in step S408, and step S410 is executed. Step S410, combine the N pieces of test data into a first test data set.
For example, after processing the attribute value list in table 3 using the first predetermined policy, a first test data set can be obtained, as shown in table 4.
TABLE 4
In the embodiment of the present invention, the generating of the first test data set by using the first preset policy for the program test may include the following advantages: 1. the robustness and fault tolerance of the program is verified using as little data volume as possible. 2. The test efficiency is ensured, and the basic requirement of data coverage can be ensured at the same time.
In addition, in order to verify as much as possible whether the program under test can meet the design requirements, a large amount of data is required for test support. The large amount of data may be all possible combinations of data obtained by arranging and combining the sorted attribute value lists. Although the data combination obtained by permutation and combination can cover all the required test information, the excessive data amount generates a large amount of redundancy, which is not beneficial to quickly performing the program test. For example, for a set of data comprising 4 attributes, each of which comprises 100 attribute values, if the attributes are arranged and combined, 4^100 pieces of data are generated, which is a very considerable amount of data. If the 4^100 pieces of data are taken as input values to test the program, the test workload can be greatly increased, and the test efficiency is reduced.
To reduce the amount of data after the permutation and combination, in some exemplary embodiments, the sorted attribute value list may be processed using a second predetermined policy to generate a second test data set.
FIG. 5 is a flow chart illustrating a method of test data generation according to another exemplary embodiment.
Referring to fig. 5, the method for generating test data according to the embodiment of the present invention may include steps S501, S502, and S503, where steps S501 and S502 may refer to steps S201 and S202 in fig. 2, and are not described herein again. Step S503, processing the attribute value list by applying a second preset policy, and generating a second data set. In an embodiment of the present invention, the second preset policy may be: the ordered list of attribute values is processed using an orthogonal algorithm to generate a second test data set. The orthogonal algorithm may be a dual test data algorithm, but the present invention is not limited thereto.
In the embodiment of the present invention, the program test performed by generating the second test data set by using the second preset policy may include the following advantages: the most comprehensive data attribute combination mode can be covered, but the data volume of the test data can be reduced to the maximum extent. The robustness and fault tolerance of the program can be verified by taking the data in the second test data set as input, so that program defects can be discovered as much as possible, and developers can be helped to modify and perfect the functions of the program subsequently.
For example, after processing the attribute value list in table 3 by using the second predetermined policy, a second test data set can be obtained, as shown in table 5.
TABLE 5
In practical applications, in order to detect the robustness and fault tolerance of a program, it is often necessary to detect the reaction of the program to erroneous inputs, which may include: the data value is not in the value range (for example, the size of the age-restricted attribute is between 1 and 120, but the input is 0), the data input type is inconsistent with the preset type (for example, the preset data type is integer, but the input value is character type), the bit number is inconsistent (for example, the input is restricted to be 4-bit number, but the input value is 5-bit number), and the like. For this reason, some noise data needs to be added to the test data when preparing the test data before the program test to check the robustness and fault tolerance of the data.
For example, the attribute age is set to be an integer type with a certain range of sizes, so that some noise data of a non-numeric type (e.g., letters, characters), a non-integer type (e.g., 10.9) or an age range (e.g., 1000) is required to be prepared at the time of testing to verify whether the program can be processed correctly.
Noise data is a random error or variation that indicates a variable that can be generated by a noise generation algorithm.
Specifically, as shown in fig. 6, generating noise data may include the following steps.
Step S601, a noise data set is acquired.
Initializing a noise data set of a common data type to obtain an initialized noise data set;
step S602, matching the types of the noise values in the noise data set according to the types of at least part of the attributes of the attribute value list, so as to obtain the noise values consistent with the types of at least part of the attributes of the attribute value list.
Before data matching, the type of at least part of attributes in the attribute value list needs to be determined, where the type of at least part of attributes in the attribute value list may be: sound attribute, age attribute, name attribute, etc.;
and performing type matching according to the types of at least part of attributes of the attribute value list and the noise values in the noise data set to acquire the noise values corresponding to the types of at least part of attributes of the attribute value list.
In order to test the robustness and fault tolerance of the program, a third test data set may be generated using a third predetermined strategy during the data preparation phase.
FIG. 7 is a flowchart illustrating a method of test data generation according to another exemplary embodiment.
Referring to fig. 7, the method for generating test data according to the embodiment of the present invention may include steps S701, S702, and S703, where steps S701 and S702 may refer to steps S201 and S202 in fig. 2, and are not described herein again. Step S703, processing the attribute value list by applying a third preset policy, and generating third test data. In an embodiment of the present invention, the third preset policy may include: processing the sorted attribute value list by using an orthogonal algorithm, wherein the orthogonal algorithm can be a full-dual test data algorithm; noise values of at least part of the attributes generated by the noise generation algorithm are added to the at least part of the attributes to generate a third test data set.
For example, a third test data set can be obtained by processing the attribute value list in table 3 with a third predetermined policy, as shown in table 6.
TABLE 6
Serial number | Name (I) | Age (age) | Nationality book | Amount of order |
1 | Li four | 20 | United states of America | 360 |
2 | Zhang three | 30 | China (China) | 360 |
3 | Li four | 30 | United states of America | 550 |
4 | Zhang three | 20 | China (China) | 550 |
5 | Li four | 20 | China (China) | 800 |
6 | Zhang three | 30 | United states of |
800 |
7 | ** | aa | The earth | Ad |
8 | () | -- | Solar system | 3*() |
In the embodiment of the present invention, the program test performed by generating the third test data set by using the third preset policy may include the following advantages: different attribute values generally have the value types, value ranges and the like which are specified, and the noise data can be added to introduce the data types which do not meet the requirements in the maximum range, so that the robustness and fault tolerance of the program can be detected.
FIG. 8 is a block diagram illustrating a test data generation apparatus according to an example embodiment. Referring to fig. 8, the apparatus 800 includes an attribute classification module 801, an attribute sorting module 802, and a test data generation module 803.
The attribute classification module 801 may be configured to classify the original data according to attributes, and obtain an attribute value list.
The attribute ordering module 802 may be configured to order each attribute item in the attribute value list.
The test data generating module 803 may be configured to apply a preset policy to process the attribute value list, so as to generate a test data set.
In an exemplary embodiment, the test data set may include any one or more of a first test data set, a second test data set, a third test data set, and so on.
In an exemplary embodiment, if the test data set is a first test data set; the test data generating module 803 may include: the first test data generation unit may be configured to extract a kth attribute value in each attribute item, respectively, and generate a kth piece of test data in the first test data set. K is a positive integer greater than or equal to 1 and less than or equal to N, and N is the maximum value of the attribute length in the attribute value list.
In an exemplary embodiment, the first test data generation unit may further include: the first test data generation subunit may be configured to, when it is determined that the attribute value length M of at least one attribute item is smaller than N, cyclically extract, in order, 1 st to M-th attribute values from the at least one attribute item and fill the 1 st to N-th attribute values of the at least one attribute item.
In an exemplary embodiment, if the test data set is the second test data set; the test data generating module 803 may further include: a second test data generation unit configured to generate test data
And processing the sorted attribute value list by using an orthogonal algorithm to generate the second test data set.
In an exemplary embodiment, if the test data is the third test data set; the test data generating module 803 may further include: the third test data generation unit may be configured to process the sorted attribute value list using an orthogonal algorithm. Noise values for at least some of the attributes in the list of attribute values are generated. And adding the generated noise value to the attribute value list after orthogonal processing to generate the third test data set.
In an exemplary embodiment, the test data generation module 803 may further include: a data reduction unit may be configured to perform data reduction on the sorted attribute value list.
In an exemplary embodiment, the data reduction includes any one or more of deduplication, dead-spotting, and error correction for each list of attribute values.
Since each functional module of the test data generation apparatus 800 according to the exemplary embodiment of the present invention corresponds to the step of the above-described exemplary embodiment of the test data generation method, it is not described herein again.
Referring now to FIG. 9, shown is a block diagram of a computer system 900 suitable for use in implementing a terminal device of an embodiment of the present application. The terminal device shown in fig. 9 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 9, the computer system 900 includes a Central Processing Unit (CPU)901 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)902 or a program loaded from a storage section 908 into a Random Access Memory (RAM) 903. In the RAM 903, various programs and data necessary for the operation of the system 900 are also stored. The CPU 901, ROM 902, and RAM 903 are connected to each other via a bus 904. An input/output (I/O) interface 905 is also connected to bus 904.
To the I/O interface 905, AN input section 906 including a keyboard, a mouse, and the like, AN output section 907 including a device such as a Cathode Ray Tube (CRT), a liquid crystal display (L CD), and the like, a speaker, and the like, a storage section 908 including a hard disk, and the like, and a communication section 909 including a network interface card such as a L AN card, a modem, and the like, the communication section 909 performs communication processing via a network such as the internet, a drive 910 is also connected to the I/O interface 905 as necessary, a removable medium 911 such as a magnetic disk, AN optical disk, a magneto-optical disk, a semiconductor memory, and the like is mounted on the drive 910 as necessary, so that a computer program read out therefrom is mounted into the storage section 908 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 909, and/or installed from the removable medium 911. The above-described functions defined in the system of the present application are executed when the computer program is executed by a Central Processing Unit (CPU) 901.
It should be noted that the computer readable medium shown in the present application may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, 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), an optical fiber, 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 present application, 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. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart 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 application. 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.
The units described in the embodiments of the present application may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a transmitting unit, an obtaining unit, a determining unit, and a first processing unit. Wherein the names of the elements do not in some way constitute a limitation on the elements themselves.
As another aspect, the present application also provides a computer-readable medium, which may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: classifying the original data according to attributes to obtain an attribute value list; sorting each of the attribute value lists; and processing the attribute value list by applying a preset strategy to generate a test data set. By adopting the test data generation method provided by the disclosure, a large amount of test data can be generated quickly and conveniently so as to facilitate software testing of testers. .
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution of the embodiment of the present invention may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.), and includes several instructions for enabling a computing device (which may be a personal computer, a server, a mobile terminal, or an intelligent device, etc.) to execute the method according to the embodiment of the present invention, such as one or more of the steps shown in fig. 2.
Furthermore, the above-described figures are merely schematic illustrations of processes involved in methods according to exemplary embodiments of the invention, and are not intended to be limiting. It will be readily understood that the processes shown in the above figures are not intended to indicate or limit the chronological order of the processes. In addition, it is also readily understood that these processes may be performed synchronously or asynchronously, e.g., in multiple modules.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It is to be understood that the invention is not limited to the details of construction, arrangement of drawings, or method of implementation, which have been set forth herein, but on the contrary, is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.
Claims (12)
1. A method for generating test data, comprising:
classifying the original data according to attributes to obtain an attribute value list;
sorting each attribute item in the attribute value list;
and processing the attribute value list by applying a preset strategy to generate a test data set.
2. The method of claim 1, wherein the test data set comprises any one or more of a first test data set, a second test data set, and a third test data set; and processing the attribute value list by applying different preset strategies to generate different test data sets.
3. The method of claim 2, wherein if the test data set is a first test data set; processing the attribute value list by applying a preset strategy to generate a test data set, wherein the method comprises the following steps:
respectively extracting the kth attribute value in each attribute item to generate the kth test data in the first test data set;
k is a positive integer greater than or equal to 1 and less than or equal to N, and N is the maximum value of the attribute length in the attribute value list.
4. The method of claim 3, further comprising:
if the length M of the attribute value of at least one attribute item is smaller than N, circularly and sequentially extracting the 1 st to M th attribute values from the at least one attribute item to be filled as the M +1 th to N th attribute values of the at least one attribute item.
5. The method of claim 2, wherein if the test data set is the second test data set; processing the attribute value list by applying a preset strategy to generate a test data set, wherein the method comprises the following steps:
and processing the sorted attribute value list by using an orthogonal algorithm to generate the second test data set.
6. The method of claim 2, wherein if the test data is the third set of test data; processing the attribute value list by applying a preset strategy to generate a test data set, wherein the method comprises the following steps:
processing the sorted attribute value list by using an orthogonal algorithm;
generating noise values of at least part of attributes in the attribute value list; and
and adding the generated noise value to the attribute value list after orthogonal processing to generate the third test data set.
7. The method of claim 6, wherein generating noise values for at least some of the attributes in the list of attribute values comprises:
acquiring a noise data set;
and matching the types of the noise values in the noise data set according to the types of at least part of attributes of the attribute value list so as to obtain the noise values consistent with the types of at least part of attributes of the attribute value list.
8. The method of claim 1, further comprising:
and carrying out data reduction on the classified attribute value list.
9. The method of claim 7, wherein the data reduction comprises performing any one or more of deduplication, dead-point removal and error correction on each attribute value list.
10. A test data generation apparatus, comprising:
the attribute classification module is configured to classify the original data according to attributes to obtain an attribute value list;
the attribute sorting module is configured to sort each attribute item in the attribute value list;
and the test data generation module is configured to apply a preset strategy to process the attribute value list to generate a test data set.
11. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-9.
12. A computer-readable medium, on which a computer program is stored, which program, when being executed by a processor, is adapted to carry out the method of any one of claims 1-9.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910018279.9A CN111427759A (en) | 2019-01-09 | 2019-01-09 | Test data generation method and device, electronic equipment and computer readable medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910018279.9A CN111427759A (en) | 2019-01-09 | 2019-01-09 | Test data generation method and device, electronic equipment and computer readable medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111427759A true CN111427759A (en) | 2020-07-17 |
Family
ID=71545956
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910018279.9A Pending CN111427759A (en) | 2019-01-09 | 2019-01-09 | Test data generation method and device, electronic equipment and computer readable medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111427759A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112632054A (en) * | 2020-12-30 | 2021-04-09 | 南京翼海云峰软件技术有限公司 | Data set duplication removing method based on attribute encryption, storage medium and system |
CN116204417A (en) * | 2023-01-09 | 2023-06-02 | 睿智合创(北京)科技有限公司 | Method for rapidly generating decision test data |
-
2019
- 2019-01-09 CN CN201910018279.9A patent/CN111427759A/en active Pending
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112632054A (en) * | 2020-12-30 | 2021-04-09 | 南京翼海云峰软件技术有限公司 | Data set duplication removing method based on attribute encryption, storage medium and system |
CN116204417A (en) * | 2023-01-09 | 2023-06-02 | 睿智合创(北京)科技有限公司 | Method for rapidly generating decision test data |
CN116204417B (en) * | 2023-01-09 | 2023-10-20 | 睿智合创(北京)科技有限公司 | Method for rapidly generating decision test data |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP3563243B1 (en) | Determining application test results using screenshot metadata | |
US8549478B2 (en) | Graphical user interface input element identification | |
CN109871311B (en) | Method and device for recommending test cases | |
US20130339787A1 (en) | Systematic failure remediation | |
CN110990276A (en) | Automatic testing method and device for interface field and storage medium | |
CN113377653B (en) | Method and device for generating test cases | |
CN111427759A (en) | Test data generation method and device, electronic equipment and computer readable medium | |
CN112148766A (en) | Method and system for sampling data using artificial neural network model | |
CN115795000A (en) | Joint similarity algorithm comparison-based enclosure identification method and device | |
US11080228B2 (en) | Distributed random binning featurization with hybrid two-level parallelism | |
US9390073B2 (en) | Electronic file comparator | |
CN113760834B (en) | File classification method, device, equipment and medium | |
CN110505289B (en) | File downloading method and device, computer readable medium and wireless communication equipment | |
US20080222149A1 (en) | Collation Regression Testing | |
CA2956155A1 (en) | Methods and apparatus for comparing different types of data | |
CN113094415A (en) | Data extraction method and device, computer readable medium and electronic equipment | |
CN115827122A (en) | Operation guiding method and device, electronic equipment and storage medium | |
CN110688295A (en) | Data testing method and device | |
CN114691527A (en) | Unit test case generation method, apparatus, device, medium, and program product | |
CN114490400A (en) | Method and device for processing test cases | |
CN111367791B (en) | Method, device, medium and electronic equipment for generating test case | |
CN103761247B (en) | A kind of processing method and processing device of error file | |
US20240265101A1 (en) | Detecting code anomalies in source code using machine learning techniques | |
CN114492413B (en) | Text proofreading method and device and electronic equipment | |
US20240242525A1 (en) | Character string pattern matching using machine learning |
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 |