Test data generation method and device, electronic device and computer readable medium

By classifying, sorting the original data at attributes and applying preset strategies to process it, multiple test data sets are generated, which solves the problem of cumbersome, repetitive and error-prone test data generation in software testing, and improves the testing efficiency and defect discovery ability.

CN111427759BActive Publication Date: 2025-02-21BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201910018279.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-01-09
Publication Date
2025-02-21
Estimated Expiration
2039-01-09

AI Technical Summary

Technical Problem

In software testing, generating and maintaining test data is cumbersome, repetitive and error-prone, especially when a large amount of test data is required, it is difficult for the prior art to achieve automated generation.

Method used

By classifying and sorting the original data at attributes, and processing the attribute value list using preset strategies, a variety of test data sets are generated, including the first test data set, the second test data set and the third test data set.

Benefits of technology

It realizes the rapid and convenient generation of test data sets, improves the efficiency of software testing, and can promptly discover the defects of software programs and help them be remedied.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111427759B_ABST
    Figure CN111427759B_ABST
Patent Text Reader

Abstract

The present disclosure provides a test data generation method, device, electronic device and computer-readable medium, the method comprising: classifying original data according to attributes to obtain an attribute value list; sorting each attribute item in the attribute value list; applying a preset strategy to process the attribute value list to generate a test data set. The test data generation method proposed in the present disclosure can automatically, quickly and conveniently generate a large amount of test data to facilitate testers to perform software testing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the fields of computers and the Internet, and in particular to a test data generating method and device, an electronic device, and a computer-readable medium. Background Art

[0002] With the advancement of computer science and technology and the rapid development of the software industry, software testing has attracted more and more attention. In software testing examples, testers usually confirm whether the logic of the software is in accordance with their expectations by modifying the input test data of the software. In actual work, the generation and maintenance of test data is a very important part of software testing, and this work is tedious, repetitive and prone to errors. Undoubtedly, it is very meaningful to find a universal data generation method.

[0003] In many test data preparation processes, data creators create test data by trial and error based on some basic documents or basic understanding of the business. Some simple data creation tasks with small amounts of data are easy to operate manually, but when a large amount of test data is required, how to let a program or a tool automatically generate the expected test data set has become one of the urgent problems to be solved in current software testing. Summary of the invention

[0004] In view of this, the present disclosure provides a test data generating method and device, an electronic device and a computer-readable medium, which can quickly create or maintain test data, improve software testing efficiency, and timely discover defects in software programs and help remedy the defects.

[0005] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.

[0006] According to one aspect of the embodiments of the present disclosure, a data generation method is proposed, which includes: classifying original data according to attributes to obtain an attribute value list; sorting each attribute item in the attribute value list; applying a preset strategy to process the attribute value list to generate a test data set.

[0007] 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; different preset strategies are applied to process the attribute value list to generate the above different test data sets.

[0008] In an exemplary embodiment of the present disclosure, if the test data set is a first test data set; wherein, applying a preset strategy to process the attribute value list to generate a test data set includes: extracting the kth attribute value in each attribute item respectively to generate the kth test data in the first test data set; wherein 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.

[0009] In an exemplary embodiment of the present disclosure, the data generation method also includes: if there is at least one attribute item whose attribute value length M is less than N, then cyclically extracting the 1st to Mth attribute values ​​from the at least one attribute item in sequence to fill the M+1th to Nth attribute values ​​of the at least one attribute item.

[0010] In an exemplary embodiment of the present disclosure, if the test data set is the second test data set; wherein, applying a preset strategy to process the attribute value list to generate a test data set includes: using an orthogonal algorithm to process the sorted attribute value list to generate the second test data set.

[0011] In an exemplary embodiment of the present disclosure, if the test data set is the third test data set; wherein, applying a preset strategy to process the attribute value list to generate a test data set includes: processing the sorted attribute value list using an orthogonal algorithm; generating noise values ​​that are consistent with at least part of the attribute types in the attribute value list; and adding the generated noise values ​​to the attribute value list after orthogonal processing to generate the third test data set.

[0012] In an exemplary embodiment of the present disclosure, generating noise values ​​for at least some of the attributes in the attribute value list includes: acquiring a noise data set; matching the type of noise values ​​in the noise data set according to the type of at least some of the attributes in the attribute value list to obtain noise values ​​that are consistent with the type of at least some of the attributes in the attribute value list.

[0013] In an exemplary embodiment of the present disclosure, the data generating method further includes: performing data reduction on the classified attribute value list.

[0014] In an exemplary embodiment of the present disclosure, the data reduction includes performing any one or more of deduplication, bad point removal, and error correction on each attribute value list.

[0015] According to a second aspect of an embodiment of the present disclosure, a test data generating device is proposed, which includes: an attribute classification module, configured to classify original data according to attributes to obtain an attribute value list; an attribute sorting module, configured to sort each attribute value list in the attribute value list; and a test data generating module, configured to apply a preset strategy to process the attribute value list to generate a test data set.

[0016] According to the third aspect of an embodiment of the present disclosure, an electronic device is proposed, which includes: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement any of the test data generation methods described above.

[0017] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable medium is provided, on which a computer program is stored, characterized in that when the program is executed by a processor, the test data generating method as described in any one of the above items is implemented.

[0018] According to the test data generation method, device, electronic device and computer-readable medium provided in certain embodiments of the present disclosure, various test data sets are generated quickly and conveniently by classifying and sorting the original data and then using a variety of different strategies to help testers complete the test.

[0019] It is to be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. The drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other drawings can also be obtained based on these drawings without creative work.

[0021] Figure 1 A schematic diagram showing an exemplary system architecture to which the test data generating method or test data generating device according to an embodiment of the present invention can be applied is shown.

[0022] Figure 2 The figure is a flowchart of a method for generating test data according to an exemplary embodiment.

[0023] Figure 3 is a flowchart of a method for generating test data according to another exemplary embodiment.

[0024] Figure 4is a flowchart of a method for generating test data according to another exemplary embodiment.

[0025] Figure 5 is a flowchart of a method for generating test data according to another exemplary embodiment.

[0026] Figure 6 is a flowchart of a method for generating test data according to another exemplary embodiment.

[0027] Figure 7 is a flow chart of a method for generating noise data according to another exemplary embodiment.

[0028] Figure 8 It is a block diagram of a test data generating device according to an exemplary embodiment.

[0029] Fig. 9 It is a structural diagram of a computer system applied to a test data generating device according to an exemplary embodiment. DETAILED DESCRIPTION

[0030] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that the present invention will be comprehensive and complete and fully convey the concepts of the example embodiments to those skilled in the art. The same reference numerals in the figures represent the same or similar parts, and thus their repeated description will be omitted.

[0031] The described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present invention. However, those skilled in the art will appreciate that the technical solution of the present invention may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid blurring various aspects of the present invention.

[0032] The accompanying drawings are only schematic illustrations of the present invention, and the same reference numerals in the drawings represent the same or similar parts, so their repeated description will be omitted. Some block diagrams shown in the accompanying drawings do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0033] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and steps, nor must they be executed in the order described. For example, some steps can be decomposed, and some steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0034] 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 used to express an open-ended inclusion and mean that additional elements / components / etc. may exist in addition to the listed elements / components / etc.; the terms "first", "second" and "third" etc. are used only as labels and are not intended to limit the quantity of their objects.

[0035] Exemplary embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0036] Figure 1 A schematic diagram showing an exemplary system architecture to which the test data generating method or test data generating device according to an embodiment of the present invention can be applied is shown.

[0037] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0038] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, etc.

[0039] 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 devices 101, 102, and 103. The background management server may analyze and process the received request data, and feed back the processing results to the terminal device.

[0040] The server 105 may, for example, classify the original data according to the attributes to obtain an attribute value list; the server 105 may, for example, sort each attribute item in the attribute value list; the server 105 may, for example, apply a preset strategy to process the attribute value list to generate a test data set.

[0041] It should be understood that Figure 1 The number of terminal devices, networks and servers in the example is only for illustration. The server 105 may be a physical server or may be composed of multiple servers. According to the implementation requirements, there may be any number of terminal devices, networks and servers. 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. Accordingly, the test data generation device is generally disposed in the server 105.

[0042] Figure 2 The figure is a flowchart of a method for generating test data according to an exemplary embodiment.

[0043] Reference Figure 2 , the test data generating method may include the following steps.

[0044] Step S201, classify the original data according to attributes to obtain an attribute value list.

[0045] In some embodiments, raw data refers to desensitized real data extracted from a production environment or online data. Data desensitization refers to the deformation of certain sensitive information through desensitization rules to achieve reliable protection of sensitive privacy data. For example, in cases involving customer security data or some commercial sensitive data, real data is transformed and provided for testing without violating system rules. Personal information such as ID card number, mobile phone number, card number, customer number, etc. all need to be desensitized.

[0046] However, the original data cannot meet the data requirements of the test software. Because when testing software, not only the correct data needs to be input to detect whether the program output is correct, but also the wrong data needs to be input to detect the difference between the program output and the expected result, so as to determine whether the software can automatically remind the fault, automatically recover, or ignore the fault and continue to run. The wrong input data type may include: wrong data type, value outside the definition domain, wrong operation sequence, abnormal interruption of communication, abnormal closure of a function, load exceeding the limit, etc.

[0047] In the embodiment of the present invention, considering the above abnormal situations, in order to test the fault tolerance and robustness of the program, after obtaining the desensitized original data, it is first necessary to extract these data, which may include: classifying the original data according to the attributes to obtain the attribute value list, and performing data reduction on the classified attribute value list according to the attributes. The data reduction includes any one or more of deduplication, bad point removal, error correction, etc. on the attribute value list. Deduplication refers to deleting redundant data in the data, bad point removal refers to deleting data that has obvious errors, and error correction refers to automatically correcting some erroneous data in the data list.

[0048] For example, the original data of customer orders are obtained from an online database. After the original data is reduced and classified according to attributes, a list of attribute values ​​as shown in Table 1 can be generated, where the attributes include: name, age, nationality, and order amount.

[0049] Table 1

[0050] Serial number Name age Country of Citizenship Order amount 1 Zhang San 20 China 550 2 Zhang San 20 China 360 3 Li Si 30 USA 800

[0051] Data reduction is performed on each attribute item in each of the above attribute value lists to obtain Table 2.

[0052] Table 2

[0053] Name age Country of Citizenship Order amount Zhang San 20 China 550 Li Si 30 USA 360 800

[0054] Step S202: sort each attribute item in the attribute value list.

[0055] In an embodiment of the present invention, after data reduction and classification of the attribute items of the desensitized original data to generate an attribute value list, it is also necessary to sort the attribute values ​​in each attribute item in the attribute value list according to a certain rule, such as: sorting numerical data in ascending order (the present disclosure is not limited to this, for example, in other embodiments, the attribute values ​​in a certain attribute item may also be arranged in descending order), and sorting text data by the first letter of the pinyin. For example, based on Table 2, sorting the numbers in the reduced attribute value list in ascending order and sorting the text in ascending order by the first letter of the pinyin can obtain the data shown in Table 3.

[0056] Table 3

[0057] Name age Country of Citizenship Order amount Li Si 20 USA 360 Zhang San 30 China 550 800

[0058] Step S203: Apply a preset strategy to process the attribute value list to generate a test data set.

[0059] In an embodiment of the present invention, after obtaining the sorted attribute value list, a preset strategy may be adopted to process the attribute value list to obtain a test data set. The preset strategy may include a first preset strategy, a second preset strategy, and a third preset strategy, and the test data set may include a first test data set, a second test data set, and a third test data set. The first preset strategy, the second preset strategy, and the third preset strategy may be adopted to generate the first test data set, the second test data set, and the third test data set, respectively.

[0060] In the embodiment of the present invention, the use of a preset strategy to generate a test data set for program testing may include the following advantages: 1. The test data set is generated quickly and conveniently to facilitate the tester to perform the test. 2. The generated test data set can not only meet the basic requirements of program testing but also ensure the efficiency of program testing. 3. The test data set can introduce noise data to test the robustness and fault tolerance of the program.

[0061] Figure 3 is a flowchart of a method for generating test data according to another exemplary embodiment.

[0062] Reference Figure 3 The test data generation method of the embodiment of the present invention may include steps S301, S302, and S303, wherein steps S301 and S302 may refer to Figure 2 Steps S201 and S202 are not repeated here. Step S303, apply the first preset strategy to process the attribute value list to generate the first test data. In an embodiment of the present invention, the above-mentioned first preset strategy may include: extracting the kth attribute value in each attribute respectively, and generating the kth test data in the first test data set; wherein 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.

[0063] In an embodiment of the present invention, if there is at least one attribute item in which the attribute value length M is less than N, the 1st to Mth attribute values ​​are extracted cyclically and sequentially from the at least one attribute item to fill the M+1th to Nth attribute values ​​of the at least one attribute item.

[0064] That is, when M is less than N / 2, the attribute values ​​in the at least one attribute item are sequentially extracted cyclically and filled into the at least one attribute item until the length of the at least one attribute item is equal to N;

[0065] When M is equal to N / 2, the first to the Mth attribute values ​​in the at least one attribute item are sequentially filled into the M+1th to the Nth attribute values ​​of the at least one attribute item;

[0066] When M is greater than N / 2, the 1st to NMth attribute values ​​in the at least one attribute item are sequentially filled into the M+1th to Nth attribute values ​​of the at least one attribute item.

[0067] For example, when M is equal to 10 and N is equal to 26, the 1st to 10th attribute values ​​in the at least one attribute item are extracted in sequence and filled into the 11th to 20th attribute values ​​in the at least one attribute item in sequence, and then the 1st to 6th attribute values ​​in the at least one attribute item are extracted again in a loop and filled into the 21st to 26th attribute values ​​in sequence in the at least one attribute item until the length of the at least one attribute item is equal to 26.

[0068] When M is equal to 13 and N is equal to 26, the 1st to 13th attribute values ​​in the at least one attribute item are extracted in sequence and filled into the 14th to 26th attribute values ​​in the at least one attribute item in sequence until the length of the at least one attribute item is equal to 26.

[0069] When M is equal to 15 and N is equal to 26, the 1st to 11th attribute values ​​in the at least one attribute item are extracted in sequence and filled into the 16th to 26th attribute values ​​in the at least one attribute item in sequence until the length of the at least one attribute item is equal to 26.

[0070] Optionally, when the test data set is generated as the first test data set, the following method may be used: Figure 4 The illustrated embodiments present a method. Figure 4 is a flowchart of a method for generating test data according to another exemplary embodiment.

[0071] In this embodiment, A represents a list of attribute values. p represents each attribute item in the attribute value list, the subscript p is greater than 1 and less than n, wherein n represents 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 attribute value position in the attribute item, i and j are only two of the position variables, in this embodiment, there are n such position variables with exactly the same functions and steps, for simplicity, their description is omitted, A p [j] means the jth attribute value in the pth attribute item in the attribute value list.

[0072] In this embodiment, the attribute value list includes multiple attribute items, and now A p Represents any property item in a property value list.

[0073] refer to Figure 4 , the test data generating method may include the following steps.

[0074] Step S401, classify the original data according to attributes and obtain attribute value list A.

[0075] Step S402: for each attribute item A in the attribute value list p After sorting, get A p '.

[0076] Steps S401 and S402 are Figure 2 The execution process of steps S201 and S202 is exactly the same and will not be repeated here.

[0077] Step S403, perform initialization operation, set the counting variable k to 0, and all n position variables to 0, for example, i to 0, j to 0.

[0078] After initializing each variable, it is necessary to extract attribute values ​​from each attribute item to form test data. p ' is used as an example to illustrate the process of extracting attribute values. Step S404, determine whether the size of j+1 is equal to attribute item A p '. If j+1 is equal to attribute item A p ', execute step S405, i.e. set j equal to 0; if the size of j+1 is not equal to attribute item A p ', execute step S406, that is, take out attribute item A p 'The jth attribute value A p '[j].

[0079] Similarly, steps S404 to S406 are executed for other attribute items in the attribute value list to retrieve the attribute values ​​at corresponding positions.

[0080] When the corresponding attribute values ​​of all attribute items are taken out, step S407 is executed. In step S407, the n attribute values ​​A taken out from the n attribute items are 1 '[i]~A p '[j] is combined into the kth test data.

[0081] Step S408, determine whether k is equal to N. If k is not equal to N, execute step S409. Step S409, set the counting variable k to k+1, and all the n attribute item position variables are incremented by 1, for example, i is equal to i+1, j is equal to j+1. Then repeat steps S404 to S09 until k is determined to be equal to N in step S408, and execute step S410. Step S410, combine N test data into a first test data set.

[0082] For example, after processing the attribute value list in Table 3 using the first preset strategy, a first test data set can be obtained, as shown in Table 4.

[0083] Table 4

[0084]

[0085]

[0086] In the embodiment of the present invention, using the first preset strategy to generate the first test data set for program testing may include the following advantages: 1. Using as little data as possible to verify the robustness and fault tolerance of the program. 2. Ensuring the efficiency of the test while ensuring the basic requirement of data coverage.

[0087] In addition, in order to verify as much as possible whether the tested program can meet the design requirements, a large amount of data is required for testing support. This large amount of data can be all possible data combinations obtained by permuting and combining the sorted attribute value list. Although the data combination obtained by permutation and combination can cover all the required test information, too much data will generate a lot of redundancy, which is not conducive to quick program testing. For example, for a set of data containing 4 attributes, each attribute includes 100 attribute values. If the attributes are permuted and combined, 4^100 pieces of data will be generated, which is a very considerable amount of data. If these 4^100 pieces of data are used as input values ​​to test the program, the testing workload will be greatly increased and the testing efficiency will be reduced.

[0088] In order to reduce the amount of data after the above permutations and combinations, in some exemplary embodiments, a second preset strategy may be used to process the sorted attribute value list to generate a second test data set.

[0089] Figure 5 is a flowchart of a method for generating test data according to another exemplary embodiment.

[0090] Reference Figure 5 The test data generation method of the embodiment of the present invention may include steps S501, S502, and S503, wherein steps S501 and S502 may refer to Figure 2 Steps S201 and S202 are not described here. Step S503, applying a second preset strategy to process the attribute value list to generate a second data set. In an embodiment of the present invention, the second preset strategy may be: using an orthogonal algorithm to process the sorted attribute value list to generate a second test data set. The orthogonal algorithm may use a dual test data algorithm, but the present invention is not limited thereto.

[0091] In the embodiment of the present invention, the second preset strategy is used to generate the second test data set for program testing, which may include the following advantages: the most comprehensive data attribute combination can be covered, while at the same time the amount of test data can be reduced to the greatest extent. By using the data in the second test data set as input to verify the robustness and fault tolerance of the program, program defects can be discovered as much as possible, so as to help developers to subsequently modify and improve program functions.

[0092] For example, after the attribute value list in Table 3 is processed by the second preset strategy, a second test data set can be obtained, as shown in Table 5.

[0093] Table 5

[0094]

[0095]

[0096] In practical applications, in order to test the robustness and fault tolerance of a program, it is usually necessary to test the program's response to erroneous input, which may include: data values ​​not within the range (for example, the age attribute is limited to between 1 and 120, but the input is 0), data input type is inconsistent with the preset type (for example, the preset data type is integer, but the input value is character), digit inconsistency (for example, the input is limited to 4 digits, but the input value is 5 digits), etc. For this reason, when preparing test data before program testing, some noise data needs to be added to the test data to test the robustness and fault tolerance of the data.

[0097] For example, the attribute age is set to an integer within a certain range, so when testing, you need to prepare some non-numeric (such as letters, text), non-integer (such as 10.9) or noise data that exceeds the age range (such as 1000) to verify whether the program can handle it correctly.

[0098] Noise data refers to the random errors or variations that occur in a variable. Noise data can be generated by a noise generation algorithm.

[0099] Specifically, Figure 6 As shown, generating noise data may include the following steps.

[0100] Step S601, obtaining a noise data set.

[0101] Initialize a noise data set of a common data type to obtain an initialized noise data set;

[0102] Step S602: Match the types of noise values ​​in the noise data set according to the types of at least some attributes in the attribute value list to obtain noise values ​​consistent with the types of at least some attributes in the attribute value list.

[0103] Before data matching, it is necessary to determine the types of at least some of the attributes in the attribute value list, wherein the types of at least some of the attributes in the attribute value list may be: voice attribute, age attribute, name attribute, etc.;

[0104] Type matching is performed according to the types of at least some of the attributes in the attribute value list and the noise values ​​in the noise data set to obtain noise values ​​corresponding to the types of at least some of the attributes in the attribute value list.

[0105] In order to test the robustness and fault tolerance of the program, a third preset strategy can be used to generate a third test data set during the data preparation stage.

[0106] Figure 7 is a flowchart of a method for generating test data according to another exemplary embodiment.

[0107] Reference Figure 7 The test data generation method of the embodiment of the present invention may include steps S701, S702, and S703, wherein steps S701 and S702 may refer to Figure 2 Steps S201 and S202 are not described here. Step S703, applying a third preset strategy to process the attribute value list to generate third test data. In an embodiment of the present invention, the third preset strategy may include: using an orthogonal algorithm to process the sorted attribute value list, and the orthogonal algorithm may be a full dual test data algorithm; adding the noise values ​​of at least part of the attributes generated by the noise generation algorithm to the at least part of the attributes to generate a third test data set.

[0108] For example, after processing the attribute value list in Table 3 using the third preset strategy, a third test data set can be obtained, as shown in Table 6.

[0109] Table 6

[0110] Serial number Name age Country of Citizenship Order amount 1 Li Si 20 USA 360 2 Zhang San 30 China 360 3 Li Si 30 USA 550 4 Zhang San 20 China 550 5 Li Si 20 China 800 6 Zhang San 30 USA 800 7 ** aa Earth Ad 8 () -- Solar System 3*()

[0111] In an embodiment of the present invention, using a third preset strategy to generate a third test data set for program testing may include the following advantages: different attribute values ​​generally have specified value types, value ranges, etc., and adding noise data can introduce data types that do not meet the requirements to the greatest extent, which can be used to detect the robustness and fault tolerance of the program.

[0112] Figure 8 is a block diagram of a test data generating device according to an exemplary embodiment. Figure 8 The device 800 includes an attribute classification module 801, an attribute sorting module 802 and a test data generation module 803.

[0113] The attribute classification module 801 may be configured to classify the original data according to attributes to obtain an attribute value list.

[0114] The attribute sorting module 802 may be configured to sort each attribute item in the attribute value list.

[0115] The test data generation module 803 may be configured to apply a preset strategy to process the attribute value list to generate a test data set.

[0116] 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 the like.

[0117] In an exemplary embodiment, if the test data set is a first test data set, the test data generation module 803 may include: a first test data generation unit, which may be configured to extract the kth attribute value in each attribute item respectively, and generate the kth test data in the first test data set. Where 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.

[0118] In an exemplary embodiment, the first test data generation unit may also include: a first test data generation sub-unit, which can be configured to, when it is determined that there is at least one attribute item whose attribute value length M is less than N, cyclically extract the 1st to Mth attribute values ​​from the at least one attribute item in sequence to fill the M+1th to Nth attribute values ​​of the at least one attribute item.

[0119] In an exemplary embodiment, if the test data set is the second test data set; wherein the test data generation module 803 may also include: a second test data generation unit, which may be configured as

[0120] The sorted attribute value list is processed using an orthogonal algorithm to generate the second test data set.

[0121] In an exemplary embodiment, if the test data is the third test data set, the test data generation module 803 may further include: a third test data generation unit, which may be configured to process the sorted attribute value list using an orthogonal algorithm, generate noise values ​​for at least some attributes in the attribute value list, and add the generated noise values ​​to the attribute value list after orthogonal processing to generate the third test data set.

[0122] In an exemplary embodiment, the test data generating module 803 may further include: a data reduction unit, which may be configured to perform data reduction on the classified attribute value list.

[0123] In an exemplary embodiment, the data reduction includes performing any one or more of deduplication, bad point removal, and error correction on each attribute value list.

[0124] Since the functional modules of the test data generating apparatus 800 of the exemplary embodiment of the present invention correspond to the steps of the exemplary embodiment of the test data generating method described above, they will not be described in detail herein.

[0125] Reference below Fig. 9 , which shows a schematic diagram of the structure of a computer system 900 of a terminal device suitable for implementing an embodiment of the present application. Fig. 9 The terminal device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0126] like Fig. 9 As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the system 900 are also stored. The CPU 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0127] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. 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 needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.

[0128] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part 909, and / or installed from a removable medium 911. When the computer program is executed by a central processing unit (CPU) 901, the above-mentioned functions defined in the system of the present application are executed.

[0129] 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 above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0130] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0131] The units involved in the embodiments described in the present application may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes a sending unit, an acquiring unit, a determining unit, and a first processing unit. The names of these units do not constitute limitations on the units themselves in some cases.

[0132] As another aspect, the present application also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device includes: classifying the original data according to attributes to obtain a list of attribute values; sorting each attribute value list in the attribute value list; applying a preset strategy to process the attribute value list to generate a test data set. By adopting the test data generation method proposed in the present disclosure, a large amount of test data can be generated quickly and conveniently to facilitate testers to perform software testing. .

[0133] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution of the embodiment of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), including a number of instructions for a computing device (which can be a personal computer, a server, a mobile terminal, or a smart device, etc.) to execute the method according to the embodiment of the present invention, for example Figure 2 One or more of the steps shown.

[0134] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.

[0135] Other embodiments of the present disclosure will be readily apparent to those skilled in the art after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art for which the present invention is not applicable. The specification and examples are to be considered merely as exemplary, and the true scope and spirit of the present invention is indicated by the claims.

[0136] It should be understood that the present invention is not limited to the detailed structures, drawings or implementations shown herein, but rather the present invention is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.

Claims

1. A test data generation method, characterized in that: include: Classify the original data according to attributes and obtain a list of attribute values; Sort each attribute item in the attribute value list; If there is at least one attribute item whose attribute value length M is less than N, then extract the 1st to Mth attribute values ​​from the at least one attribute item in a cyclic manner and fill them as the M+1th to Nth attribute values ​​of the at least one attribute item; Applying a preset strategy to process the attribute value list to generate a test data set; The test data set includes a first test data set; The method of applying a preset strategy to process the attribute value list to generate a test data set includes: Extracting the kth attribute value in each attribute item respectively to generate the kth test data in the first test data set; Where 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; If there is at least one attribute item whose attribute value length M is less than N, then cyclically extracting the 1st to Mth attribute values ​​from the at least one attribute item in sequence to fill the M+1th to Nth attribute values ​​of the at least one attribute item, including: When M is less than N / 2, extract attribute values ​​from the at least one attribute item in sequence and fill them into the at least one attribute item in a loop until the length of the at least one attribute item is equal to N; When M is equal to N / 2, the first to the Mth attribute values ​​in the at least one attribute item are sequentially filled into the M+1th to the Nth attribute values ​​of the at least one attribute item; When M is greater than N / 2, the 1st to NMth attribute values ​​in the at least one attribute item are sequentially filled into the M+1th to Nth attribute values ​​of the at least one attribute item.

2. The method according to claim 1, characterized in that: The test data set also includes any one or more of a second test data set and a third test data set; different preset strategies are applied to process the attribute value list to generate the above different test data sets.

3. The method according to claim 2, characterized in that: If the test data set is the second test data set, wherein applying a preset strategy to process the attribute value list to generate a test data set includes: The sorted attribute value list is processed using an orthogonal algorithm to generate the second test data set.

4. The method according to claim 2, characterized in that: If the test data is the third test data set, wherein applying a preset strategy to process the attribute value list to generate a test data set includes: Use an orthogonal algorithm to process the sorted attribute value list; generating noise values ​​for at least some of the attributes in the attribute value list; and The generated noise value is added to the attribute value list after orthogonal processing to generate the third test data set.

5. The method according to claim 4, characterized in that: The generating of noise values ​​of at least some attributes in the attribute value list comprises: Get the noisy dataset; The types of noise values ​​in the noise data set are matched according to the types of at least some of the attributes in the attribute value list to obtain noise values ​​consistent with the types of at least some of the attributes in the attribute value list.

6. The method according to claim 1, characterized in that: Also includes: Perform data reduction on the classified attribute value list.

7. The method according to claim 6, characterized in that: The data reduction includes performing any one or more of deduplication, bad point removal, and error correction on each attribute value list.

8. A test data generating device, characterized in that: include: An attribute classification module is configured to classify the original data according to the attributes and obtain a list of attribute values; An attribute sorting module, configured to sort each attribute item in the attribute value list; If there is at least one attribute item whose attribute value length M is less than N, then extract the 1st to Mth attribute values ​​from the at least one attribute item in a cyclic manner and fill them as the M+1th to Nth attribute values ​​of the at least one attribute item; A test data generation module, configured to apply a preset strategy to process the attribute value list to generate a test data set; The test data set includes a first test data set; The method of applying a preset strategy to process the attribute value list to generate a test data set includes: Extracting the kth attribute value in each attribute item respectively to generate the kth test data in the first test data set; Where 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; If there is at least one attribute item whose attribute value length M is less than N, then cyclically extracting the 1st to Mth attribute values ​​from the at least one attribute item in sequence to fill the M+1th to Nth attribute values ​​of the at least one attribute item, including: When M is less than N / 2, extract attribute values ​​from the at least one attribute item in sequence and fill them into the at least one attribute item in a loop until the length of the at least one attribute item is equal to N; When M is equal to N / 2, the first to the Mth attribute values ​​in the at least one attribute item are sequentially filled into the M+1th to the Nth attribute values ​​of the at least one attribute item; When M is greater than N / 2, the 1st to NMth attribute values ​​in the at least one attribute item are sequentially filled into the M+1th to Nth attribute values ​​of the at least one attribute item.

9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.

10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Method for processing report data, reporting system and related device thereof

    CN101727436A

  • Method and device for generating test case

    CN107102941A