CN109901987B - Method and device for generating test data - Google Patents

Method and device for generating test data Download PDF

Info

Publication number
CN109901987B
CN109901987B CN201711306525.8A CN201711306525A CN109901987B CN 109901987 B CN109901987 B CN 109901987B CN 201711306525 A CN201711306525 A CN 201711306525A CN 109901987 B CN109901987 B CN 109901987B
Authority
CN
China
Prior art keywords
data
preset
generating
test data
expected result
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.)
Active
Application number
CN201711306525.8A
Other languages
Chinese (zh)
Other versions
CN109901987A (en
Inventor
马春荣
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201711306525.8A priority Critical patent/CN109901987B/en
Publication of CN109901987A publication Critical patent/CN109901987A/en
Application granted granted Critical
Publication of CN109901987B publication Critical patent/CN109901987B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method and a device for generating test data, and relates to the technical field of computers. One embodiment of the method comprises: constructing expected result data of the task to be tested; and reversely generating test data according to a preset reverse flow chart according to a generation rule of the expected result data in the task to be tested. The test data can be generated quickly, accurately and automatically, and the test data of the abnormal flow can be generated easily, so that the test efficiency is improved.

Description

Method and device for generating test data
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for generating test data.
Background
When testing a timing task, a data table used in each step in the business process needs to be constructed, different processes are tested, and different data needs to be constructed. And testing the whole business process, constructing a data value required by each link of the whole business process, running a task, and verifying result data. The test data construction is a relatively complex work, currently, a single task module needs to construct data in a plurality of data tables respectively, an expected result is calculated through the constructed test data, then the task module carries out comparison according to an actual result of data operation, and if a plurality of modules are correlated, the complexity is higher, and the constructed data is more complex.
The data for constructing these task modules currently mainly goes through two ways: the first mode is to list the data tables needed by the timing task module, then draw the association relation among the data tables, respectively construct according to the data tables, and insert a single piece of data; the second mode is to list the data tables needed by the task module, write a storage process according to the incidence relation among the data tables, and insert data in batches.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
the problems of large manual workload, complicated work content, more time consumption, easy omission and insufficient intelligence are solved;
the second method can solve the problem of constructing data in batches, but cannot complete data of abnormal flows.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for generating test data, which can generate test data quickly, accurately and automatically, and also can generate test data of an abnormal flow easily, thereby improving test efficiency.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method of generating test data.
A method of generating test data, comprising: constructing expected result data of the task to be tested; and reversely generating test data according to a preset reverse flow chart according to a generation rule of the expected result data in the task to be tested.
Optionally, the generation rule is: performing preset judgment by using a condition key field of a source table where the test data is located, so as to generate the expected result data; the step of generating the test data reversely according to the preset reverse flow chart comprises the following steps: traversing expected result data of each flow branch of the preset reverse flow chart; and for each expected result data, judging whether the preset value of the condition key field of each source table required for generating the expected result data is 1, if so, generating the data of 1 as the test data of the corresponding source table, and otherwise, generating the data of 0 as the test data of the corresponding source table.
Optionally, the generation rule is: copying preset fields of each source table where the test data are located, and generating expected result data; the step of generating the test data reversely according to the preset reverse flow chart comprises the following steps: traversing expected result data of each flow branch of the preset reverse flow chart; for each expected result data, reading a preset field of each source table required for generating the expected result data and a preset value of the preset field; and reversely copying the preset field and the preset value of the preset field to the corresponding source table to generate the test data of the corresponding source table.
Optionally, the generation rule is: performing preset operation by using the relevant fields of the first source table and the second source table where the test data is located, so as to generate the expected result data; the step of generating the test data reversely according to the preset reverse flow chart comprises the following steps: traversing expected result data of each flow branch of the preset reverse flow chart; randomly generating a random number which is larger than zero and smaller than the value of the expected result data, and using the random number as the test data of the first source table; and generating the test data of the second source table according to the test data of the first source table and the expected result data and the reverse operation of the preset operation.
Optionally, the preset operation comprises field value addition, and/or field value multiplication.
According to another aspect of the embodiments of the present invention, there is provided an apparatus for generating test data.
An apparatus to generate test data, comprising: the construction module is used for constructing expected result data of the tested task; and the generating module is used for reversely generating test data according to a preset reverse flow chart according to a generating rule of the expected result data in the task to be tested.
Optionally, the generation rule is: performing preset judgment by using a condition key field of a source table where the test data is located, so as to generate the expected result data; the generation module is further to: traversing expected result data of each flow branch of the preset reverse flow chart; and for each expected result data, judging whether the preset value of the condition key field of each source table required for generating the expected result data is 1, if so, generating the data of 1 as the test data of the corresponding source table, and otherwise, generating the data of 0 as the test data of the corresponding source table.
Optionally, the generation rule is: copying preset fields of each source table where the test data are located, and generating expected result data; the generation module is further configured to: traversing expected result data of each flow branch of the preset reverse flow chart; for each expected result data, reading a preset field of each source table required for generating the expected result data and a preset value of the preset field; and reversely copying the preset field and the preset value of the preset field to the corresponding source table to generate the test data of the corresponding source table.
Optionally, the generation rule is: performing preset operation by using the relevant fields of the first source table and the second source table where the test data is located, so as to generate expected result data; the generation module is further to: traversing expected result data of each flow branch of the preset reverse flow chart; randomly generating a random number greater than zero and less than the value of the expected result data, the random number being used as test data of the first source table; and generating the test data of the second source table according to the test data of the first source table and the expected result data and the reverse operation of the preset operation.
Optionally, the preset operation comprises field value addition, and/or field value multiplication.
According to yet another aspect of an embodiment of the present invention, an electronic device is provided.
An electronic device, comprising: one or more processors; a memory for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement the method of generating test data provided by the present invention.
According to yet another aspect of an embodiment of the present invention, a computer-readable medium is provided.
A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method of generating test data according to the invention.
One embodiment of the above invention has the following advantages or benefits: constructing expected result data of the task to be tested; and reversely generating test data according to a preset reverse flow chart according to a generation rule of expected result data in the task to be tested. The test data can be generated quickly, accurately and automatically, and the test data of the abnormal flow can be generated easily, so that the test efficiency is improved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a method of generating test data according to an embodiment of the invention;
FIG. 2 is a schematic illustration of a reverse flow diagram of a method of generating test data according to an embodiment of the invention;
FIG. 3 is a schematic illustration of a reverse flow chart of a method of generating test data according to yet another embodiment of the invention;
FIG. 4 is a schematic illustration of a reverse flow chart of a method of generating test data according to yet another embodiment of the invention;
FIG. 5 is a schematic diagram of the main blocks of an apparatus for generating test data according to an embodiment of the present invention;
FIG. 6 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
FIG. 7 is a schematic block diagram of a computer system suitable for use with a server implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Because the data in the test process is more complicated to construct step by step, the data required in the process of generating the flow by reversing the result data is easier. Based on the inventive concept, the invention constructs a reverse flow chart of the timing task testing flow by reversely analyzing the flow state of the timing task module, lists result data, utilizes program languages such as java language and the like as guidance by result, and automatically generates all data required by testing the whole service flow by reverse reasoning based on the constructed reverse flow chart.
Fig. 1 is a schematic diagram of main steps of a method of generating test data according to an embodiment of the present invention.
As shown in fig. 1, the method for generating test data according to the embodiment of the present invention mainly includes the following steps S101 to S102.
Step S101: and constructing expected result data of the task to be tested.
The expected result data may be set according to the requirements of the test task, according to the expected result required.
Step S102: and reversely generating test data according to a preset reverse flow chart and a generation rule of expected result data in the task to be tested.
Wherein, the generation rule may be: and performing preset judgment by using the condition key field of the source table where the test data is located, so as to generate expected result data. The rule of the preset decision may be to and the conditional key fields of the source table to decide to generate expected result data of logical True (i.e., True) or logical False (i.e., False). Correspondingly, the step of generating the test data reversely according to the preset reverse flow chart may specifically include: traversing expected result data of each flow branch of a preset reverse flow chart; and for each expected result data, judging whether the preset value of the condition key field of each source table required for generating the expected result data is 1, if so, generating the data of 1 as the test data of the corresponding source table, and otherwise, generating the data of 0 as the test data of the corresponding source table.
The generation rule may also be: and copying preset fields of each source table where the test data are located, so as to generate expected result data. Correspondingly, the step of reversely generating the test data according to the preset reverse flow chart may specifically include: traversing expected result data of each flow branch of a preset reverse flow chart; for each expected result data, reading a preset field of each source table required for generating the expected result data and a preset value of the preset field; and reversely copying the preset field and the preset value of the preset field to the corresponding source table to generate the test data of the corresponding source table.
The generation rule may also be: and performing preset operation by using the relevant fields of the first source table and the second source table where the test data is positioned, so as to generate expected result data. Correspondingly, the step of generating the test data reversely according to the preset reverse flow chart may specifically include: traversing expected result data of each flow branch of a preset reverse flow chart; randomly generating a random number which is larger than zero and smaller than the value of the expected result data, and using the random number as the test data of the first source table; and generating the test data of the second source table according to the reverse operation of the preset operation according to the test data and the expected result data of the first source table. The preset operation may include: field value addition, and/or field value multiplication.
By the method for generating the test data, the test data in the required process can be generated in a reverse manner step by setting the expected result data in the process, performing data tracking reversely according to the expected result data, and generating the test data in the required process step by step, so that the test data can be generated quickly, accurately and automatically, and the test data of the abnormal process can be generated easily. For clarity of the present invention, the following description will be made by taking specific scenarios.
The first embodiment is as follows:
in one embodiment, the result data is generated based on a predetermined determination of the source table data, and the data in the source table and the condition may be generated by a reverse determination.
Step one, the expected result data, the data table of the source (i.e. the source table) and the conditions required by the preset judgment are listed. Taking a source table as a data table a and a data table B as an example, the data table a and the data table B are associated through an associated field wid, and in order to generate expected result data, a preset judgment needs to be performed on condition key fields corresponding to the same associated field (that is, wid values are the same) in the data table a and the data table B.
Table 1 is a data information table of the present embodiment, which includes expected result data, a data table of sources (i.e., a source table), and conditions required for performing the preset determination, where the expected result data are True and False, and the conditions required for performing the preset determination are:
when the expected result data (also called result state) is True, it needs corresponding associated field wid 10001, condition key field ynA is 1 in data table a, and condition key field ynB is 1 in data table B;
when the expected result data is False, it needs the corresponding associated field wid to be 10002, the condition key field ynA in table a is 0, and the condition key field ynB in table B is 1, or wid to be 10003, the ynA is 1 and ynB is 0, or wid to be 10004, the ynA and the ynB are both 0.
TABLE 1
The associated field is wid Status of results ynA data Table A ynB in data Table B
10001 Ture 1 1
10002 False 0 1
10003 False 1 0
10004 False 0 0
FIG. 2 is a schematic diagram of a reverse flow diagram of a method of generating test data according to one embodiment of the invention.
Step two, according to the reverse flow chart shown in fig. 2, the expected result data corresponds to two branches, the True branch and the False branch. A data module may be set for each source table to generate test data, for example, a data module a is set for data table a, and a data module B is set for data table B, specifically, the data module a may be further divided into two sub-modules, for example, when ynA is equal to 1, the corresponding sub-module a1, and ynA is equal to 0, the corresponding sub-module a 0; accordingly, data block B may be divided into two sub-blocks, with ynB equal to 1 for sub-block B1 and ynB equal to 0 for sub-block B0. If the expected result needs to be True, test data is generated through the branches of sub-module a1 and sub-module B1, and if the expected result needs to be False, test data can be generated through the branches of sub-module a0 and sub-module B1, sub-module a1 and sub-module B0, sub-module a0 and sub-module B0, respectively, so that through the reverse flow chart shown in fig. 2, required test data in all flows are automatically generated according to the set generation rules.
And circularly traversing each branch corresponding to the expected result data, taking out the corresponding associated field wid, judging whether yn in the set data information table is 1, if ynA in the data table A is 1, generating data information which is 1 in the data table A according to the rule of the submodule A1, and if ynA is 0, generating data information which is 0 in the data table A according to the rule of the submodule A0. Therefore, the test data of the data table in the process is automatically generated by sequentially circulating, so that the aim of automatically generating the required source data through the set expected result data is fulfilled.
Wherein, the rule of each sub-module can be: through the associated field wid, the condition key field generated by the submodule a1 is 1, i.e. ynA inserted into the data table a is 1; the condition key field generated by submodule a0 is 0, that is, ynA in the inserted data table a is 0, and similarly, the condition key field generated by submodule B1 is 1, that is, ynB in the inserted data table B is 1; the conditional key field generated by submodule B0 is 0, i.e. ynB in insert data Table B is 0. For example, the expected result data is tune, the corresponding associated field wid is 10001, determine ynA if it is equal to 1, if so, sub-module a1 generates data information of 1 in data table a, and takes the value of wid field to insert into data table a, where the piece of test data corresponding to the generated data table a is: wid 10001 and ynA 1.
Tables 2 and 3 are the test data in the generated data table a and data table B, respectively.
TABLE 2
The associated field is wid ynA data Table A
10001 1
10002 0
10003 1
10004 0
TABLE 3
The associated field is wid ynB in data Table B
10001 1
10002 1
10003 0
10004 0
Example two:
in another embodiment, the result data is derived from a copy of the process data (i.e., test data) and is associated with a wid field in the source table by an associated field wid, such as a commodity code.
Step one, listing the relationship between the result data and the source table (namely the data table of the test data source).
Take the example that the result data is derived from the data information in data table a and data table B. Table 4 is a table of result data information (also referred to as a result table) that includes expected result data and a relationship between the expected result data and the source table. As shown in Table 4, the expected results data include A1, A2, A3 field sources and data table A, B1, B2 field sources and data table B.
TABLE 4
Figure BDA0001502053490000101
And step two, reading fields and preset values of the fields of the data table A and the data table B required for generating the expected result data by circularly traversing the expected result data, and reversely copying the preset values of the fields and the fields from the result table shown in the table 4 to the source tables (the data table A and the data table B), thereby generating the test data of each source table.
Fig. 3 is a schematic diagram of a reverse flow chart of the method for generating test data according to the present embodiment.
As shown in fig. 3, first, the commodity code in the result table, the first-level classification field a1 in the data table a, the second-level classification field a2 in the data table a, and the third-level classification field A3 in the data table a are read, and the test data in the data table a is generated by reverse copy; then, the commodity code, the distribution center field B1 in B in the data table, and the library attribute field B2 in B in the data table are read, and the test data in the data table B is generated by reverse copying. Thereby generating success for all test data of the source table required for the expected result data.
The reverse flow chart shown in fig. 3 may also read the commodity code in the result table, the distribution center field B1 in the data table B, and the warehouse attribute field B2 in the data table B, and generate the test data in the data table B by reverse copying; then, the commodity code in the result table, the first class field a1 in the data table a, the second class field a2 in the data table a, and the third class field A3 in the data table a are read, and the test data in the data table a is generated by reverse copying. In addition, the source tables of the method for generating test data in this embodiment may be two or more, and when there are a plurality of source tables, the test data of each source table may be generated by reverse copying one by one according to the above method in this embodiment.
The test data in the generated data table a and data table B are shown in table 5 and table 6, respectively.
TABLE 5
Figure BDA0001502053490000111
TABLE 6
Figure BDA0001502053490000121
Example three:
in another embodiment, the result data is derived from the calculation of a data table without cross-relationships. A data table without cross relationship means that the generation relationship between the source table where the test data is located and the data table where the result data is located is not related to the third party data table, for example, data table A, B, C, where the data table where the expected result data corresponding to the data table A, B where the test data is located is C, then the data table A, B without cross relationship is: data table a and data table B can no longer be generated from data in data tables other than data table C.
Step one, the result data is associated with the data table a and the data table B through the associated field wid, the C field in the result table is the sum of the field a1 of the source data table a and the field B1 of the data table B, and the D field in the result table is the multiplication of the field a2 of the data table a and the field B2 of the data table B. Results table data is shown in table 7.
TABLE 7
Figure BDA0001502053490000122
Fig. 4 is a schematic diagram of a reverse flowchart of the method of generating test data according to the present embodiment. The process shown in FIG. 4 is described in detail in step two below.
Step two, circulating the data of the result table, acquiring the values of wid, C and D fields, randomly generating numbers within the value of the C field, assigning the generated numbers to the field A1 in the data table A, subtracting the randomly generated numbers from the value of the C field, and assigning the subtracted result to the field B1 in the data table B; the value of the D field is then randomly generated as a number and assigned to data table A field A2, and the result of the division is assigned to field B2 in the data table by dividing the value of the D field by the value of the randomly generated number, thereby generating the data value from the source table by the data value of the expected result data.
Taking the data in the result table shown in table 7 as an example, for wid of 10001, the expected result data is constructed with the C field 10 and the D field 24, assuming that a number within the C field 10 is randomly generated and is 6, and the value 6 of the random number is assigned to the field a1 in the data table a, and then the result 4 is assigned to the field B1 in the data table B by subtracting the random number 6 from the C field 10; then, a number 8 within the value 24 of the D field is randomly generated, the random number 8 is assigned to a field a2 of the data table a, the D field value 24 is divided by the value 8 of the randomly generated number to obtain a result of 3, the result value 3 is assigned to a field B2 of the data table, and similarly, for wid of 10002, it is assumed that a randomly generated random number 70 is assigned to a field a1 of the data table a and a randomly generated random number 2 is assigned to a field a2 of the data table a, and the value of a field B1 of the data table B is 30 and the value of a field B2 of the data table B is 6. The resulting data tables a and B are table 8 and table 9, respectively.
TABLE 8
The associated field is wid Source data Table A field A1 Source data Table A field A2
10001 6 8
10002 70 2
TABLE 9
The associated field is wid Source data Table B field B1 Source data Table B field B2
10001 4 3
10002 30 6
Fig. 5 is a schematic diagram of main blocks of an apparatus for generating test data according to an embodiment of the present invention.
As shown in fig. 5, the apparatus 500 for generating test data according to the embodiment of the present invention mainly includes: a constructing module 501 and a generating module 502.
The construction module 501 is used to construct expected result data of the task under test.
The generating module 502 is configured to generate the test data reversely according to a preset reverse flow chart according to a generating rule of the expected result data in the task under test.
Wherein, the generation rule may be: and performing preset judgment by using the condition key field of the source table where the test data is located, so as to generate expected result data. Accordingly, the generating module 502 may be specifically configured to: traversing expected result data of each flow branch of a preset reverse flow chart; and for each expected result data, judging whether the preset value of the condition key field of each source table required for generating the expected result data is 1, if so, generating the data of 1 as the test data of the corresponding source table, and otherwise, generating the data of 0 as the test data of the corresponding source table.
The generation rule may also be: and copying preset fields of each source table where the test data are located, so as to generate expected result data. Accordingly, the generating module 502 may be specifically configured to: traversing expected result data of each flow branch of a preset reverse flow chart; for each expected result data, reading a preset field of each source table required for generating the expected result data and a preset value of the preset field; and reversely copying the preset fields and the preset values of the preset fields to the corresponding source table to generate the test data of the corresponding source table.
The generation rule may also be: and performing preset operation by using the relevant fields of the first source table and the second source table where the test data is positioned, so as to generate expected result data. Accordingly, the generating module 502 may be specifically configured to: traversing expected result data of each flow branch of a preset reverse flow chart; randomly generating a random number which is larger than zero and smaller than the value of the expected result data, and using the random number as the test data of the first source table; and generating the test data of the second source table according to the reverse operation of the preset operation according to the test data and the expected result data of the first source table.
The preset operation may include field value addition, and/or field value multiplication.
In addition, the detailed implementation of the apparatus for generating test data in the embodiment of the present invention has been described in detail in the above method for generating test data, and therefore, the repeated description is not repeated here.
Fig. 6 illustrates an exemplary system architecture 600 to which the method of generating test data or the apparatus for generating test data of embodiments of the present invention may be applied.
As shown in fig. 6, the system architecture 600 may include terminal devices 601, 602, 603, a network 604, and a server 605. The network 604 serves as a medium for providing communication links between the terminal devices 601, 602, 603 and the server 605. Network 604 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 601, 602, 603 to interact with the server 605 via the network 604 to receive or send messages or the like. Various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, and the like, may be installed on the terminal devices 601, 602, and 603.
The terminal devices 601, 602, 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 605 may be a server that provides various services, such as a background management server that supports shopping websites browsed by users using the terminal devices 601, 602, and 603. The background management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (e.g., product information) to the terminal device.
It should be noted that the method for generating test data provided by the embodiment of the present invention is generally executed by the server 605, and accordingly, the apparatus for generating test data is generally disposed in the server 605.
It should be understood that the number of terminal devices, networks, and servers in fig. 6 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 7, shown is a block diagram of a computer system 700 suitable for use in implementing a server according to embodiments of the present application. The server shown in fig. 7 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. 7, the computer system 700 includes a Central Processing Unit (CPU)701, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the system 700 are also stored. The CPU 701, ROM 702, and RAM 703 are connected to each other via a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
The following components are connected to the I/O interface 705: an input portion 706 including a keyboard, a mouse, and the like; an output section 707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 708 including a hard disk and the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. A drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read out therefrom is mounted into the storage section 708 as necessary.
In particular, according to the embodiments 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 can be downloaded and installed from a network through the communication section 709, and/or installed from the removable medium 711. The computer program executes the above-described functions defined in the system of the present application when executed by the Central Processing Unit (CPU) 701.
It should be noted that the computer readable medium shown in the present invention can 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 modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor comprises a construction module 501, a generation module 502. Where the names of these modules do not in some cases constitute a limitation on the module itself, for example, the construction module 501 may also be described as a "module for constructing expected result data for a task under test".
As another aspect, the present invention also provides a computer-readable medium that 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: constructing expected result data of the task to be tested; and reversely generating test data according to a preset reverse flow chart according to a generation rule of the expected result data in the task to be tested.
According to the technical scheme of the embodiment of the invention, expected result data of the task to be tested is constructed; and reversely generating test data according to a preset reverse flow chart according to a generation rule of expected result data in the task to be tested. The test data can be generated quickly, accurately and automatically, and the test data of abnormal processes can be generated easily, so that the test efficiency is improved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (12)

1. A method of generating test data, comprising:
constructing expected result data of the task to be tested;
according to a generation rule of the expected result data in the task to be tested, generating test data reversely according to a preset reverse flow chart, wherein a first rule of the generation rule is as follows: and performing preset judgment by using a condition key field of a source table where the test data is located, so as to generate the expected result data.
2. The method according to claim 1, wherein the first rule is a generation rule according to which the test data is generated reversely according to a preset reverse flow chart;
the step of generating the test data reversely according to the preset reverse flow chart comprises the following steps:
traversing expected result data of each flow branch of the preset reverse flow chart;
and for each expected result data, judging whether the preset value of the condition key field of each source table required for generating the expected result data is 1, if so, generating the data of 1 as the test data of the corresponding source table, and otherwise, generating the data of 0 as the test data of the corresponding source table.
3. The method of claim 1, wherein a second rule of the generating rules is: copying preset fields of source tables where the test data are located, and accordingly generating expected result data;
generating test data reversely according to a preset reverse flow chart, wherein the generation rule according to which the test data are generated is the second rule;
the step of reversely generating test data according to a preset reverse flow chart comprises the following steps:
traversing expected result data of each flow branch of the preset reverse flow chart;
for each expected result data, reading a preset field of each source table required for generating the expected result data and a preset value of the preset field;
and reversely copying the preset field and the preset value of the preset field to the corresponding source table to generate the test data of the corresponding source table.
4. The method of claim 1, wherein a third rule of the generating rules is: performing preset operation by using the relevant fields of the first source table and the second source table where the test data is located, so as to generate the expected result data;
generating test data reversely according to a preset reverse flow chart according to a generation rule which is the third rule;
the step of generating the test data reversely according to the preset reverse flow chart comprises the following steps:
traversing expected result data of each flow branch of the preset reverse flow chart;
randomly generating a random number which is larger than zero and smaller than the value of the expected result data, and using the random number as the test data of the first source table;
and generating the test data of the second source table according to the test data of the first source table and the expected result data and the reverse operation of the preset operation.
5. The method according to claim 4, wherein the predetermined operation comprises field value addition and/or field value multiplication.
6. An apparatus for generating test data, comprising:
the construction module is used for constructing expected result data of the tested task;
a generating module, configured to generate test data reversely according to a preset reverse flow chart according to a generating rule of the expected result data in the task under test, where a first rule of the generating rule is: and performing preset judgment by using a condition key field of a source table where the test data is located, so as to generate the expected result data.
7. The apparatus of claim 6, wherein the first rule is a generation rule according to which the test data is generated reversely according to a preset reverse flow chart;
the generation module is further to:
traversing expected result data of each flow branch of the preset reverse flow chart;
and for each expected result data, judging whether the preset value of the condition key field of each source table required for generating the expected result data is 1, if so, generating the data of 1 as the test data of the corresponding source table, and otherwise, generating the data of 0 as the test data of the corresponding source table.
8. The apparatus of claim 6, wherein a second rule of the generating rules is: copying preset fields of each source table where the test data are located, and generating expected result data;
generating test data reversely according to a preset reverse flow chart, wherein the generation rule according to which the test data are generated is the second rule;
the generation module is further to:
traversing expected result data of each flow branch of the preset reverse flow chart;
for each expected result data, reading a preset field of each source table required for generating the expected result data and a preset value of the preset field;
and reversely copying the preset field and the preset value of the preset field to the corresponding source table to generate the test data of the corresponding source table.
9. The apparatus of claim 6, wherein a third rule of the generation rules is: performing preset operation by using the relevant fields of the first source table and the second source table where the test data is located, so as to generate expected result data;
generating test data reversely according to a preset reverse flow chart according to a generation rule which is the third rule;
the generation module is further to:
traversing expected result data of each flow branch of the preset reverse flow chart;
randomly generating a random number greater than zero and less than the value of the expected result data, the random number being used as test data of the first source table;
and generating the test data of the second source table according to the test data of the first source table and the expected result data and the reverse operation of the preset operation.
10. The apparatus of claim 9, wherein the predetermined operation comprises field value addition and/or field value multiplication.
11. An electronic device, comprising:
one or more processors;
a memory for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method recited in any of claims 1-5.
12. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-5.
CN201711306525.8A 2017-12-11 2017-12-11 Method and device for generating test data Active CN109901987B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711306525.8A CN109901987B (en) 2017-12-11 2017-12-11 Method and device for generating test data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711306525.8A CN109901987B (en) 2017-12-11 2017-12-11 Method and device for generating test data

Publications (2)

Publication Number Publication Date
CN109901987A CN109901987A (en) 2019-06-18
CN109901987B true CN109901987B (en) 2022-07-05

Family

ID=66941984

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711306525.8A Active CN109901987B (en) 2017-12-11 2017-12-11 Method and device for generating test data

Country Status (1)

Country Link
CN (1) CN109901987B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110532180A (en) * 2019-08-15 2019-12-03 中国银行股份有限公司 A kind of generation method and device of test data
CN112632992B (en) * 2019-09-24 2023-09-29 北京京东振世信息技术有限公司 Test method, test device, computer equipment and medium
CN111444094B (en) * 2020-03-25 2023-08-04 中国邮政储蓄银行股份有限公司 Test data generation method and system
CN111382083B (en) * 2020-04-30 2024-02-23 中国银行股份有限公司 Test data generation method and device
CN111813651B (en) * 2020-05-28 2023-07-04 杭州览众数据科技有限公司 Data exception testing method and automatic testing tool related to whole-table structure
CN112346989B (en) * 2020-11-26 2023-06-20 网易(杭州)网络有限公司 Interface testing method, device, medium and computing equipment

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101950269A (en) * 2010-08-30 2011-01-19 清华大学 Automatic test method for software members

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH03201035A (en) * 1989-10-24 1991-09-02 Matsushita Electric Ind Co Ltd Inspection series generating method
CN102323906B (en) * 2011-09-08 2014-01-08 哈尔滨工程大学 MC/DC test data automatic generation method based on genetic algorithm
CN104346366B (en) * 2013-07-30 2017-11-24 国际商业机器公司 Extend the method and apparatus of test data
CN103440201B (en) * 2013-09-05 2016-05-18 北京邮电大学 Dynamically stain analytical equipment and the application in file format resolving inversely thereof
CN104375942B (en) * 2014-12-11 2017-02-08 无锡江南计算技术研究所 Binary oriented hybrid fuzzing method
CN106021114B (en) * 2016-06-02 2018-07-10 北京光年无限科技有限公司 Towards the automated testing method and system of intelligent robot

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101950269A (en) * 2010-08-30 2011-01-19 清华大学 Automatic test method for software members

Also Published As

Publication number Publication date
CN109901987A (en) 2019-06-18

Similar Documents

Publication Publication Date Title
CN109901987B (en) Method and device for generating test data
CN107506495B (en) Information pushing method and device
CN109933514B (en) Data testing method and device
CN108933695B (en) Method and apparatus for processing information
CN111046237B (en) User behavior data processing method and device, electronic equipment and readable medium
CN109871311B (en) Method and device for recommending test cases
CN113076153B (en) Interface calling method and device
CN110795315A (en) Method and device for monitoring service
CN109062560B (en) Method and apparatus for generating information
US20150142786A1 (en) Modification of cloud application service levels based upon document consumption
CN107291835B (en) Search term recommendation method and device
CN111401684A (en) Task processing method and device
CN113989058A (en) Service generation method and device
CN110865797A (en) Method and device for processing dynamic attributes of services
CN116560661A (en) Code optimization method, device, equipment and storage medium
CN112052152A (en) Simulation test method and device
CN111026629A (en) Method and device for automatically generating test script
CN109857838B (en) Method and apparatus for generating information
CN112799797A (en) Task management method and device
CN111753111A (en) Picture searching method and device
CN111199437A (en) Data processing method and device
CN113360765B (en) Event information processing method and device, electronic equipment and medium
CN111460273B (en) Information pushing method and device
CN108537659B (en) Method and apparatus for outputting information
US20170124201A1 (en) Detecting relevant facets by leveraging diagram identification, social media and statistical analysis software

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
GR01 Patent grant
GR01 Patent grant