CN109901987A - A kind of method and apparatus generating test data - Google Patents
A kind of method and apparatus generating test data Download PDFInfo
- Publication number
- CN109901987A CN109901987A CN201711306525.8A CN201711306525A CN109901987A CN 109901987 A CN109901987 A CN 109901987A CN 201711306525 A CN201711306525 A CN 201711306525A CN 109901987 A CN109901987 A CN 109901987A
- Authority
- CN
- China
- Prior art keywords
- data
- expected results
- test data
- source table
- preset
- 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.)
- Granted
Links
Landscapes
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a kind of method and apparatus for generating test data, are related to field of computer technology.One specific embodiment of this method includes: to construct the expected results data of tested task;According to create-rule of the expected results data in the tested task, test data is inversely generated according to preset reverse flow chart.Can quickly, it is accurate, automatically generate test data, and the test data of abnormal process can also be easily produced, improve testing efficiency.
Description
Technical field
The present invention relates to field of computer technology more particularly to a kind of method and apparatus for generating test data.
Background technique
When testing timed task, needs to construct tables of data used in each step in this operation flow, test different
Process will construct different data.Entire operation flow is tested, needs to construct number required for each link of entire operation flow
According to value, task of reruning goes verification result data.Constructing test data is a comparatively laborious job, and test is single at present
Task module needs construct data in multiple tables of data respectively, then calculate expected result by the test data of construction, then
It is compared by task module according to the actual result of data run, if multiple modules are associated, complexity meeting
Bigger, construction data can be more complicated.
The data for constructing these task modules at present mainly pass through two ways: first way is timed task module
Required tables of data is listed, and the incidence relation between tables of data is then marked, and is constructed respectively according to tables of data, and insertion is single
Data;The second way is that tables of data required for task module is set out to come, and according to the incidence relation between tables of data, is compiled
A storing process is write, batch is inserted into data.
In realizing process of the present invention, at least there are the following problems in the prior art for inventor's discovery:
Labor workload is big, action is cumbersome, it is time-consuming it is more, be easy to appear omission, problem not smart enough;
Although the problem of batch constructs data may be implemented in the above-mentioned second way, but also for the data of abnormal process
It is to be unable to complete.
Summary of the invention
In view of this, the embodiment of the present invention provides a kind of method and apparatus for generating test data, can quickly, it is accurate,
Test data is automatically generated, and the test data of abnormal process can also be easily produced, improves testing efficiency.
To achieve the above object, according to an aspect of an embodiment of the present invention, a kind of side for generating test data is provided
Method.
A method of generating test data, comprising: construct the expected results data of tested task;According to the expected knot
Create-rule of the fruit data in the tested task inversely generates test data according to preset reverse flow chart.
Optionally, the create-rule are as follows: carried out using the condition keyword section of source table where the test data pre-
If determining, to generate the expected results data;The step of inversely generating test data according to preset reverse flow chart, packet
It includes: the expected results data of each flow chart branches of the traversal preset reverse flow chart;For each expected results data, sentence
Whether medium well is 1 at the preset value of the condition keyword section of each source table needed for the expected results data, if so, generating
For 1 test data of the data as corresponding source table, otherwise, it is generated as the test data of 0 data as corresponding source table.
Optionally, the create-rule are as follows: the preset field of each source table where the test data is copied,
To generate the expected results data;The step of inversely generating test data according to preset reverse flow chart, comprising: traversal
The expected results data of each flow chart branches of the preset reverse flow chart;For each expected results data, reads and generate
The preset value of the preset field and the preset field of each source table needed for the expected results data;By the preset field and
The preset value of the preset field inversely copies corresponding source table to, to generate the test data of corresponding source table.
Optionally, the create-rule are as follows: utilize the first source table and second source table where the test data
Relevant field carries out default operation, to generate the expected results data;Survey is inversely generated according to preset reverse flow chart
The step of trying data, comprising: the expected results data of each flow chart branches of the traversal preset reverse flow chart;It is random to generate
The random number of value greater than zero and less than the expected results data, using the random number as the test of first source table
Data;According to the test data of first source table and the expected results data, according to the reverse fortune of the default operation
Calculate the test data for generating the second source table.
Optionally, the default operation includes that field value addition and/or field value are multiplied.
According to another aspect of an embodiment of the present invention, a kind of device for generating test data is provided.
A kind of device generating test data, comprising: constructing module, for constructing the expected results data of tested task;
Generation module, for the create-rule according to the expected results data in the tested task, according to preset reverse flow
Journey figure inversely generates test data.
Optionally, the create-rule are as follows: carried out using the condition keyword section of source table where the test data pre-
If determining, to generate the expected results data;The generation module is also used to: the traversal preset reverse flow chart
The expected results data of each flow chart branches;For each expected results data, judge every needed for generating the expected results data
Whether the preset value of the condition keyword section of a source table is 1, if so, being generated as the survey of 1 data as corresponding source table
Data are tried, otherwise, are generated as the test data of 0 data as corresponding source table.
Optionally, the create-rule are as follows: the preset field of each source table where the test data is copied,
To generate the expected results data;The generation module is also used to: each process of the traversal preset reverse flow chart
The expected results data of branch;For each expected results data, each source needed for generating the expected results data is read
The preset value of the preset field of table and the preset field;The preset value of the preset field and the preset field is inversely copied
To corresponding source table, to generate the test data of corresponding source table.
Optionally, the create-rule are as follows: utilize the first source table and second source table where the test data
Relevant field carries out default operation, to generate the expected results data;The generation module is also used to: traversal is described default
Reverse flow chart each flow chart branches expected results data;Random generate is greater than zero and is less than the expected results data
The random number of value, using the random number as the test data of first source table;According to the test of first source table
Data and the expected results data, the test number of the second source table is generated according to the reverse operation of the default operation
According to.
Optionally, the default operation includes that field value addition and/or field value are multiplied.
Another aspect according to an embodiment of the present invention, provides a kind of electronic equipment.
A kind of electronic equipment, comprising: one or more processors;Memory works as institute for storing one or more programs
When stating one or more programs and being executed by one or more of processors, so that one or more of processors realize this hair
The method of the generation test data of bright offer.
Another aspect according to an embodiment of the present invention, provides a kind of computer-readable medium.
A kind of computer-readable medium is stored thereon with computer program, realizes this when described program is executed by processor
The method that the generation test data provided is provided.
One embodiment in foregoing invention has the following advantages that or the utility model has the advantages that constructs the expected results number of tested task
According to;According to create-rule of the expected results data in tested task, test number is inversely generated according to preset reverse flow chart
According to.Can quickly, it is accurate, automatically generate test data, and the test data of abnormal process can also easily be given birth to
At raising testing efficiency.
Further effect possessed by above-mentioned non-usual optional way adds hereinafter in conjunction with specific embodiment
With explanation.
Detailed description of the invention
Attached drawing for a better understanding of the present invention, does not constitute an undue limitation on the present invention.Wherein:
Fig. 1 is the key step schematic diagram of the method according to an embodiment of the present invention for generating test data;
Fig. 2 is the schematic diagram of the reverse flow chart of the method according to an embodiment of the invention for generating test data;
Fig. 3 is the signal of the reverse flow chart of the method for generation test data according to still another embodiment of the invention
Figure;
Fig. 4 is the signal of the reverse flow chart of the method for generation test data according to still another embodiment of the invention
Figure;
Fig. 5 is the main modular schematic diagram of the device according to an embodiment of the present invention for generating test data;
Fig. 6 is that the embodiment of the present invention can be applied to exemplary system architecture figure therein;
Fig. 7 is adapted for the structural schematic diagram for the computer system for realizing the server of the embodiment of the present invention.
Specific embodiment
Below in conjunction with attached drawing, an exemplary embodiment of the present invention will be described, including the various of the embodiment of the present invention
Details should think them only exemplary to help understanding.Therefore, those of ordinary skill in the art should recognize
It arrives, it can be with various changes and modifications are made to the embodiments described herein, without departing from scope and spirit of the present invention.Together
Sample, for clarity and conciseness, descriptions of well-known functions and structures are omitted from the following description.
It is comparatively laborious due to gradually constructing the data in test process, but product process mistake is inversely gone by result data
Required data are easier in journey.The present invention is based on foregoing invention designs, pass through the flow state to timed task module
Resolving inversely constructs the reverse flow chart to timed task testing process, first lists result data, is guiding, benefit with result
With program languages such as java language, the reverse flow chart based on construction, backward inference is automatically generated in the entire operation flow of test
Required all data.
Fig. 1 is the key step schematic diagram of the method according to an embodiment of the present invention for generating test data.
As shown in Figure 1, the method for the generation test data of the embodiment of the present invention mainly includes the following steps, namely S101 to step
Rapid S102.
Step S101: the expected results data of tested task are constructed.
The expected results data can be arranged according to the demand of test assignment according to required expected results.
Step S102: according to create-rule of the expected results data in tested task, according to preset reverse flow chart
It is reverse to generate test data.
Wherein, create-rule can be with are as follows: default judgement is carried out using the condition keyword section of source table where test data,
To generate expected results data.The default rule determined, which can be, to be carried out and is grasped by the condition keyword section of source table
Make, therefore, it is determined that generating the expected results data of logical truth (i.e. True) or logical falsehood (i.e. False).Correspondingly, according to default
Reverse flow chart the step of inversely generating test data, can specifically include: each process of the preset reverse flow chart of traversal
The expected results data of branch;For each expected results data, each source needed for generating the expected results data is judged
Whether the preset value of the condition keyword section of table is 1, if so, it is generated as the test data of 1 data as corresponding source table,
Otherwise, it is generated as the test data of 0 data as corresponding source table.
Create-rule can be with are as follows: copies to the preset field of each source table where test data, to generate
Expected results data.Correspondingly, the step of inversely generating test data according to preset reverse flow chart, can specifically include:
Traverse the expected results data of each flow chart branches of preset reverse flow chart;For each expected results data, reads and generate
The preset value of the preset field and the preset field of each source table needed for the expected results data;By preset field and this is pre-
If the preset value of field inversely copies corresponding source table to, to generate the test data of corresponding source table.
Create-rule can be with are as follows: using the first source table and second source table where test data relevant field into
The default operation of row, to generate expected results data.Correspondingly, test data is inversely generated according to preset reverse flow chart
Step can specifically include: the expected results data of each flow chart branches of the preset reverse flow chart of traversal;Random generate is greater than
Zero and be less than expected results data value random number, using random number as the test data of the first source table;According to first come
The test data and expected results data of source table generate the test data of second source table according to the reverse operation of default operation.
Wherein, default operation may include: that field value addition and/or field value are multiplied.
The method of generation test data through the embodiment of the present invention, by the expected results data in setting process, and
According to expected results data, data tracking is inversely carried out, the test data during reversed generation is required step by step, energy
It is enough quickly, it is accurate, automatically generate test data, and the test data of abnormal process can also be easily produced.For
Clearly illustrate the present invention, concrete scene is set forth below and is illustrated.
Embodiment one:
In one embodiment, result data is the default judgement based on source table data and generates, then can be with
By inversely determining come the data and condition in the generating resource table.
Step 1 lists expected results data, the tables of data in source (i.e. source table) and the required item of default judgement
Part.By taking source table is tables of data A and tables of data B as an example, tables of data A and tables of data B are associated by associate field wid,
Expected results data are generated, are needed to the condition for corresponding to same associate field (i.e. wid value is identical) in data Table A and tables of data B
Critical field carries out default judgement.
Table 1 includes expected results data, the tables of data in source (i.e. source table) and default judgement institute for the present embodiment
The data information table of the condition needed, wherein expected results data are True and False, execute item required for default judgement
Part are as follows:
When expected results data (also known as result phase) is True, corresponding associate field wid=10001, data are needed
Table A conditional critical field ynA is 1, and tables of data B conditional critical field ynB is 1;
When expected results data are False, corresponding associate field wid=10002 is needed, tables of data A conditional is crucial
Field ynA is 0, and tables of data B conditional critical field ynB is 1, alternatively, wid=10003, the ynA are 1 and ynB is 0, or
Person, wid=10004, the ynA and the ynB are 0.
Table 1
Associate field is wid | Result phase | YnA in tables of data A | YnB in tables of data B |
10001 | Ture | 1 | 1 |
10002 | False | 0 | 1 |
10003 | False | 1 | 0 |
10004 | False | 0 | 0 |
Fig. 2 is the schematic diagram of the reverse flow chart of the method according to an embodiment of the invention for generating test data.
Step 2, reverse flow chart according to Fig.2, it is contemplated that result data corresponds to Liang Ge branch, True branch and
False branch.Each source table can be corresponded to, one data module is set for generating test data, such as corresponding data Table A
One data modules A is set, and a data module B is arranged in corresponding data table B, and specifically, data module A can also be divided into two sons
Module, for example, ynA is enabled to correspond to submodule A1 when being equal to 1, ynA is equal to 0 corresponding submodule A0;Correspondingly, data module B can also
To be divided into two submodules, ynB is enabled to be equal to 1 corresponding submodule B1, ynB is equal to 0 corresponding submodule B0.If it is expected that result need
Will be True, then test data is generated by the branch of submodule A1 and submodule B1, if it is expected that result needs be
False can pass through point of submodule A0 and submodule B1, submodule A1 and submodule B0, submodule A0 and submodule B0 respectively
Branch is to generate test data, and in this way by reverse flow chart shown in Fig. 2, the test datas of the needs in all processes is according to setting
The create-rule set automatically generates.
By looping through the corresponding each branch of expected results data, corresponding associate field wid is taken out, is set by determining
Whether yn is 1 in fixed data information table, if ynA=1 in tables of data A, is generated in tables of data A according to the rule of submodule A1
The data information in tables of data A for 0 is generated according to the rule of submodule A0 if ynA=0 for 1 data information.In this way,
It circuits sequentially, the test data of the tables of data in process is all automatically generated, thus reach the expected results data by setting,
The purpose that required derived data is all automatically generated.
Wherein, the rule of each submodule can be with are as follows: passes through associate field wid, the condition keyword section that submodule A1 is generated
It is 1, i.e., the ynA in insertion data Table A is 1;The condition keyword section that submodule A0 is generated is 0, i.e. ynA in insertion data Table A
It is 0, similarly, the condition keyword section that submodule B1 is generated is 1, i.e. ynB in insertion tables of data B is 1;What submodule B0 was generated
Condition keyword section is 0, i.e. ynB is 0 in insertion tables of data B.For example, it is contemplated that result data be Ture, corresponding associated characters
Section wid=10001, judges whether ynA is equal to 1, if so, submodule A1 generates the data information in tables of data A for 1, takes wid
Field value is inserted into data Table A, this test data of the corresponding tables of data A generated are as follows: wid=10001, ynA=1.
Table 2 and table 3 are respectively the test data in the tables of data A and tables of data B generated.
Table 2
Associate field is wid | YnA in tables of data A |
10001 | 1 |
10002 | 0 |
10003 | 1 |
10004 | 0 |
Table 3
Associate field is wid | YnB in tables of data B |
10001 | 1 |
10002 | 1 |
10003 | 0 |
10004 | 0 |
Embodiment two:
In another embodiment, result data derives from the copy of process data (i.e. test data), also, result
Data are associated with by associate field wid with wid field in the table of source, which is, for example, commodity code.
Step 1 lists the relationship in result data and source table (i.e. the tables of data in test data source).
By taking result data is from the data information in tables of data A and tables of data B as an example.Table 4 be include expected results number
The result data information table (alternatively referred to as result table) of relationship accordingly and between expected results data and source table.Such as 4 institute of table
Show, it is contemplated that A1, A2, A3 field source and tables of data A, B1, B2 field source and tables of data B in result data.
Table 4
Step 2, by loop through expected results data, read generate the expected results data needed for tables of data A and
The result table of the preset value of field and field as shown in Table 4 is inversely copied to by the field of tables of data B and the preset value of field
Source table (tables of data A and tables of data B), to generate the test data of each source table.
Fig. 3 is the schematic diagram of the reverse flow chart of the method for the generation test data of the present embodiment.
As shown in figure 3, reading the commodity code in result table, first-level class field A1, tables of data A in tables of data A first
Three-level sorting field A3 in middle secondary classification field A2, tables of data A, the test number in tables of data A is generated by inversely copying
According to;Then, commodity code, home-delivery center field B1 in B in tables of data are read, storehouse attribute field B2 in B in tables of data, passed through
Reverse copy is to generate the test data in tables of data B.To the test data of source table required for expected results data
It all generates successfully.
Reverse flow chart shown in Fig. 3 can also read commodity code in result table first, in tables of data in B in dispatching
Storehouse attribute field B2 in B, the test data in tables of data B is generated by inversely copying in heart field B1, tables of data;So
Afterwards, then read commodity code in result table, secondary classification field A2 in first-level class field A1, tables of data A in tables of data A,
Three-level sorting field A3 in tables of data A, the test data in tables of data A is generated by inversely copying.Also, the present embodiment
The source table for generating the method for test data can be that two or more can be according to when source table is multiple situations
The above method of the present embodiment inversely copies the test data for generating each source table one by one.
Test data difference in the tables of data A and tables of data B of generation is as shown in table 5 and table 6.
Table 5
Table 6
Embodiment three:
In another embodiment, calculating of the result data from the not tables of data of cross reference.Do not intersect
The tables of data of relationship refers to production Methods and third between the tables of data where source table and result data where test data
Square tables of data is unrelated, for example, tables of data A, B, C, the wherein corresponding expected results data institute of tables of data A, B where test data
Tables of data be C, then tables of data A, B for the relationship that do not intersect is i.e.: tables of data A and tables of data B cannot again by remove data
Data in other tables of data except table C generate.
Step 1, result data are associated by associate field wid and data Table A and tables of data B, as a result C word in table
The sum of the field B1 of the field A1 and tables of data B of Duan Laiyuan derived data Table A, as a result in table D field derive from tables of data A word
Section A2 is multiplied with the field B2 of tables of data B.As a result table data are as shown in table 7.
Table 7
Fig. 4 is the schematic diagram of the reverse flow chart of the method for the generation test data of the present embodiment.Process tool shown in Fig. 4
Body step two as described below.
Step 2 recycles result table data, obtains field wid value, C field value and D field value, is first randomly generated C
Number within the value of field, and the value of the number of the generation is assigned to the field A1 in tables of data A, then subtracted by C field value
The value for removing the number generated at random, the result that this is subtracted each other are assigned to the field B1 in tables of data B;Then D is generated at random
The value of field with number, and the value of the number is assigned to tables of data A field A2, then generate at random divided by this by D field value
Several values, the result that this is divided by are assigned to the field B2 in tables of data, thus pass through the data value of expected results data,
Carry out the data value of the generating resource table.
With result table data instance shown in table 7, for wid=10001, constructing expected result data C field is 10,
D field is 24, it is assumed that generating the number within a C field value 10 at random is 6, and the value of the random number 6 is assigned to tables of data A
In field A1, the random number 6 is then subtracted by C field value 10, obtained result 4 is assigned to the field B1 in tables of data B;
Then the number 8 within the value 24 of D field is generated at random, and the random number 8 is assigned to tables of data A field A2, then pass through D field
For value 24 divided by the value 8 of the number generated at random, obtaining result is 3, which is assigned to the field B2 in tables of data, together
Sample, for wid=10002, it is assumed that random to generate field A1, the random generation random number 2 that random number 70 is assigned in tables of data A
It is assigned to tables of data A field A2, the value by the field B1 in the available tables of data B of the above method is 30, in tables of data
The value of field B2 is 6.Obtained tables of data A and tables of data B is respectively table 8 and table 9.
Table 8
Associate field is wid | Derived data Table A field A1 | Derived data Table A field A2 |
10001 | 6 | 8 |
10002 | 70 | 2 |
Table 9
Associate field is wid | Derived data table B field B1 | Derived data table B field B2 |
10001 | 4 | 3 |
10002 | 30 | 6 |
Fig. 5 is the main modular schematic diagram of the device according to an embodiment of the present invention for generating test data.
As shown in figure 5, the device 500 of the generation test data of the embodiment of the present invention specifically includes that constructing module 501, life
At module 502.
Constructing module 501 is used to construct the expected results data of tested task.
Generation module 502 is used for the create-rule according to expected results data in tested task, according to preset reverse
Flow chart inversely generates test data.
Wherein, create-rule can be with are as follows: default judgement is carried out using the condition keyword section of source table where test data,
To generate expected results data.Correspondingly, generation module 502 specifically can be used for: traverse each of preset reverse flow chart
The expected results data of flow chart branches;Each of for each expected results data, judge needed for generating the expected results data
Whether the preset value of the condition keyword section of source table is 1, if so, being generated as the test of 1 data as corresponding source table
Otherwise data are generated as the test data of 0 data as corresponding source table.
Create-rule can be with are as follows: copies to the preset field of each source table where test data, to generate
Expected results data.Correspondingly, generation module 502 specifically can be used for: each flow chart branches of the preset reverse flow chart of traversal
Expected results data;For each expected results data, each source table needed for generating the expected results data is read
The preset value of preset field and the preset field;The preset value of preset field and preset field is inversely copied to corresponding source
Table, to generate the test data of corresponding source table.
Create-rule can be with are as follows: using the first source table and second source table where test data relevant field into
The default operation of row, to generate expected results data.Correspondingly, generation module 502 specifically can be used for: traversal is preset reverse
The expected results data of each flow chart branches of flow chart;It is random to generate the random of the value for greater than zero and being less than expected results data
Number, using the random number as the test data of the first source table;According to the test data and expected results data of the first source table,
The test data of second source table is generated according to the reverse operation of default operation.
Default operation may include that field value addition and/or field value are multiplied.
In addition, generating the specific implementation content of the device of test data, generation described above in embodiments of the present invention
It has been described in detail in the method for test data, therefore has no longer illustrated in this duplicate contents.
Fig. 6 is shown can be using the method for the generation test data of the embodiment of the present invention or the device of generation test data
Exemplary system architecture 600.
As shown in fig. 6, system architecture 600 may include terminal device 601,602,603, network 604 and server 605.
Network 604 between terminal device 601,602,603 and server 605 to provide the medium of communication link.Network 604 can be with
Including various connection types, such as wired, wireless communication link or fiber optic cables etc..
User can be used terminal device 601,602,603 and be interacted by network 604 with server 605, to receive or send out
Send message etc..Various telecommunication customer end applications, such as the application of shopping class, net can be installed on terminal device 601,602,603
The application of page browsing device, searching class application, instant messaging tools, mailbox client, social platform software etc..
Terminal device 601,602,603 can be the various electronic equipments with display screen and supported web page browsing, packet
Include but be not limited to smart phone, tablet computer, pocket computer on knee and desktop computer etc..
Server 605 can be to provide the server of various services, such as utilize terminal device 601,602,603 to user
The shopping class website browsed provides the back-stage management server supported.Back-stage management server can believe the product received
The data such as breath inquiry request carry out the processing such as analyzing, and processing result (such as product information) is fed back to terminal device.
It should be noted that the method for generating test data provided by the embodiment of the present invention is generally held by server 605
Row, correspondingly, the device for generating test data is generally positioned in server 605.
It should be understood that the number of terminal device, network and server in Fig. 6 is only schematical.According to realization need
It wants, can have any number of terminal device, network and server.
Below with reference to Fig. 7, it illustrates the computer systems 700 for the server for being suitable for being used to realize the embodiment of the present application
Structural schematic diagram.Server shown in Fig. 7 is only an example, should not function and use scope band to the embodiment of the present application
Carry out any restrictions.
As shown in fig. 7, computer system 700 includes central processing unit (CPU) 701, it can be read-only according to being stored in
Program in memory (ROM) 702 or be loaded into the program in random access storage device (RAM) 703 from storage section 708 and
Execute various movements appropriate and processing.In RAM 703, also it is stored with system 700 and operates required various programs and data.
CPU 701, ROM 702 and RAM 703 are connected with each other by bus 704.Input/output (I/O) interface 705 is also connected to always
Line 704.
I/O interface 705 is connected to lower component: the importation 706 including keyboard, mouse etc.;It is penetrated including such as cathode
The output par, c 707 of spool (CRT), liquid crystal display (LCD) etc. and loudspeaker etc.;Storage section 708 including hard disk etc.;
And the communications portion 709 of the network interface card including LAN card, modem etc..Communications portion 709 via such as because
The network of spy's net executes communication process.Driver 710 is also connected to I/O interface 705 as needed.Detachable media 711, such as
Disk, CD, magneto-optic disk, semiconductor memory etc. are mounted on as needed on driver 710, in order to read from thereon
Computer program be mounted into storage section 708 as needed.
Particularly, disclosed embodiment, the process described above with reference to flow chart may be implemented as counting according to the present invention
Calculation machine software program.For example, embodiment disclosed by the invention includes a kind of computer program product comprising be carried on computer
Computer program on readable medium, the computer program include the program code for method shown in execution flow chart.?
In such embodiment, which can be downloaded and installed from network by communications portion 709, and/or from can
Medium 711 is dismantled to be mounted.When the computer program is executed by central processing unit (CPU) 701, the system that executes the application
The above-mentioned function of middle restriction.
It should be noted that computer-readable medium shown in the present invention can be computer-readable signal media or meter
Calculation machine readable storage medium storing program for executing either the two any combination.Computer readable storage medium for example can be --- but not
Be limited to --- electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor system, device or device, or any above combination.Meter
The more specific example of calculation machine readable storage medium storing program for executing can include but is not limited to: have the electrical connection, just of one or more conducting wires
Taking formula computer disk, hard disk, random access storage device (RAM), read-only memory (ROM), erasable type may be programmed read-only storage
Device (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), light storage device, magnetic memory device,
Or above-mentioned any appropriate combination.In this application, computer readable storage medium can be it is any include or storage journey
The tangible medium of sequence, the program can be commanded execution system, device or device use or in connection.And at this
In application, computer-readable signal media may include in a base band or as carrier wave a part propagate data-signal,
Wherein carry computer-readable program code.The data-signal of this propagation can take various forms, including but unlimited
In electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be that computer can
Any computer-readable medium other than storage medium is read, which can send, propagates or transmit and be used for
By the use of instruction execution system, device or device or program in connection.Include on computer-readable medium
Program code can transmit with any suitable medium, including but not limited to: wireless, electric wire, optical cable, RF etc. are above-mentioned
Any appropriate combination.
Flow chart and block diagram in attached drawing are illustrated according to the system of the various embodiments of the application, method and computer journey
The architecture, function and operation in the cards of sequence product.In this regard, each box in flowchart or block diagram can generation
A part of one module, program segment or code of table, a part of above-mentioned module, program segment or code include one or more
Executable instruction for implementing the specified logical function.It should also be noted that in some implementations as replacements, institute in box
The function of mark can also occur in a different order than that indicated in the drawings.For example, two boxes succeedingly indicated are practical
On can be basically executed in parallel, they can also be executed in the opposite order sometimes, and this depends on the function involved.Also it wants
It is noted that the combination of each box in block diagram or flow chart and the box in block diagram or flow chart, can use and execute rule
The dedicated hardware based systems of fixed functions or operations is realized, or can use the group of specialized hardware and computer instruction
It closes to realize.
Being described in module involved in the embodiment of the present invention can be realized by way of software, can also be by hard
The mode of part is realized.Described module also can be set in the processor, for example, can be described as: a kind of processor packet
Include constructing module 501, generation module 502.Wherein, the title of these modules is not constituted to the module itself under certain conditions
Restriction, for example, constructing module 501 is also described as " for constructing the module of the expected results data of tested task ".
As on the other hand, the present invention also provides a kind of computer-readable medium, which be can be
Included in equipment described in above-described embodiment;It is also possible to individualism, and without in the supplying equipment.Above-mentioned calculating
Machine readable medium carries one or more program, when said one or multiple programs are executed by the equipment, makes
Obtaining the equipment includes: to construct the expected results data of tested task;According to the expected results data in the tested task
Create-rule, inversely generate test data according to preset reverse flow chart.
Technical solution according to an embodiment of the present invention constructs the expected results data of tested task;According to expected results number
According to the create-rule in tested task, test data is inversely generated according to preset reverse flow chart.Can quickly, it is accurate,
Test data is automatically generated, and the test data of abnormal process can also be easily produced, improves testing efficiency.
Above-mentioned specific embodiment, does not constitute a limitation on the scope of protection of the present invention.Those skilled in the art should be bright
It is white, design requirement and other factors are depended on, various modifications, combination, sub-portfolio and substitution can occur.It is any
Made modifications, equivalent substitutions and improvements etc. within the spirit and principles in the present invention, should be included in the scope of the present invention
Within.
Claims (12)
1. a kind of method for generating test data characterized by comprising
Construct the expected results data of tested task;
According to create-rule of the expected results data in the tested task, inversely given birth to according to preset reverse flow chart
At test data.
2. the method according to claim 1, wherein the create-rule are as follows: using where the test data
The condition keyword section of source table carries out default judgement, to generate the expected results data;
The step of inversely generating test data according to preset reverse flow chart, comprising:
Traverse the expected results data of each flow chart branches of the preset reverse flow chart;
For each expected results data, the condition keyword section of each source table needed for generating the expected results data is judged
Preset value whether be 1, if so, otherwise being generated as the test data of 1 data as corresponding source table is generated as 0 number
According to the test data as corresponding source table.
3. the method according to claim 1, wherein the create-rule are as follows: to where the test data
The preset field of each source table is copied, to generate the expected results data;
The step of inversely generating test data according to preset reverse flow chart, comprising:
Traverse the expected results data of each flow chart branches of the preset reverse flow chart;
For each expected results data, reads the preset field of each source table needed for generating the expected results data and be somebody's turn to do
The preset value of preset field;
The preset value of the preset field and the preset field is inversely copied to corresponding source table to, to generate corresponding source table
Test data.
4. the method according to claim 1, wherein the create-rule are as follows: using where the test data
The first source table and the relevant field of second source table carry out default operation, to generate the expected results data;
The step of inversely generating test data according to preset reverse flow chart, comprising:
Traverse the expected results data of each flow chart branches of the preset reverse flow chart;
It is random to generate the random number for being greater than zero and the value less than the expected results data, using the random number as described first
The test data of source table;
According to the test data of first source table and the expected results data, according to the reverse operation of the default operation
Generate the test data of the second source table.
5. according to the method described in claim 4, it is characterized in that, the default operation includes field value addition and/or field
Value is multiplied.
6. a kind of device for generating test data characterized by comprising
Constructing module, for constructing the expected results data of tested task;
Generation module, for the create-rule according to the expected results data in the tested task, according to preset inverse
Test data is inversely generated to flow chart.
7. device according to claim 6, which is characterized in that the create-rule are as follows: using where the test data
The condition keyword section of source table carries out default judgement, to generate the expected results data;
The generation module is also used to:
Traverse the expected results data of each flow chart branches of the preset reverse flow chart;
For each expected results data, the condition keyword section of each source table needed for generating the expected results data is judged
Preset value whether be 1, if so, otherwise being generated as the test data of 1 data as corresponding source table is generated as 0 number
According to the test data as corresponding source table.
8. device according to claim 6, which is characterized in that the create-rule are as follows: to where the test data
The preset field of each source table is copied, to generate the expected results data;
The generation module is also used to:
Traverse the expected results data of each flow chart branches of the preset reverse flow chart;
For each expected results data, reads the preset field of each source table needed for generating the expected results data and be somebody's turn to do
The preset value of preset field;
The preset value of the preset field and the preset field is inversely copied to corresponding source table to, to generate corresponding source table
Test data.
9. device according to claim 6, which is characterized in that the create-rule are as follows: using where the test data
The first source table and the relevant field of second source table carry out default operation, to generate the expected results data;
The generation module is also used to:
Traverse the expected results data of each flow chart branches of the preset reverse flow chart;
It is random to generate the random number for being greater than zero and the value less than the expected results data, using the random number as described first
The test data of source table;
According to the test data of first source table and the expected results data, according to the reverse operation of the default operation
Generate the test data of the second source table.
10. device according to claim 9, which is characterized in that the default operation includes field value addition and/or word
Segment value is multiplied.
11. a kind of electronic equipment characterized by comprising
One or more processors;
Memory, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processors
Realize such as method as claimed in any one of claims 1 to 5.
12. a kind of computer-readable medium, is stored thereon with computer program, which is characterized in that described program is held by processor
Such as method as claimed in any one of claims 1 to 5 is realized when row.
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 true CN109901987A (en) | 2019-06-18 |
CN109901987B 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) |
Cited By (6)
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 |
CN111382083A (en) * | 2020-04-30 | 2020-07-07 | 中国银行股份有限公司 | Test data generation method and device |
CN111444094A (en) * | 2020-03-25 | 2020-07-24 | 中国邮政储蓄银行股份有限公司 | Test data generation method and system |
CN111813651A (en) * | 2020-05-28 | 2020-10-23 | 杭州览众数据科技有限公司 | Data abnormity testing method related to whole table structure and automatic testing tool |
CN112346989A (en) * | 2020-11-26 | 2021-02-09 | 网易(杭州)网络有限公司 | Interface testing method, device, medium and computing equipment |
CN112632992A (en) * | 2019-09-24 | 2021-04-09 | 北京京东振世信息技术有限公司 | Test method, test apparatus, computer device, and medium |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5305328A (en) * | 1989-10-24 | 1994-04-19 | Matsushita Electric Industrial Co., Ltd. | Method of test sequence generation |
CN101950269A (en) * | 2010-08-30 | 2011-01-19 | 清华大学 | Automatic test method for software members |
CN102323906A (en) * | 2011-09-08 | 2012-01-18 | 哈尔滨工程大学 | MC/DC test data automatic generation method based on genetic algorithm |
CN103440201A (en) * | 2013-09-05 | 2013-12-11 | 北京邮电大学 | Dynamic taint analysis device and application thereof to document format reverse analysis |
US20150039591A1 (en) * | 2013-07-30 | 2015-02-05 | International Business Machines Corporation | Method and apparatus for proliferating testing data |
CN104375942A (en) * | 2014-12-11 | 2015-02-25 | 无锡江南计算技术研究所 | Binary oriented hybrid fuzzing method |
CN106021114A (en) * | 2016-06-02 | 2016-10-12 | 北京光年无限科技有限公司 | Automated testing method and system for intelligent robot |
-
2017
- 2017-12-11 CN CN201711306525.8A patent/CN109901987B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5305328A (en) * | 1989-10-24 | 1994-04-19 | Matsushita Electric Industrial Co., Ltd. | Method of test sequence generation |
CN101950269A (en) * | 2010-08-30 | 2011-01-19 | 清华大学 | Automatic test method for software members |
CN102323906A (en) * | 2011-09-08 | 2012-01-18 | 哈尔滨工程大学 | MC/DC test data automatic generation method based on genetic algorithm |
US20150039591A1 (en) * | 2013-07-30 | 2015-02-05 | International Business Machines Corporation | Method and apparatus for proliferating testing data |
CN103440201A (en) * | 2013-09-05 | 2013-12-11 | 北京邮电大学 | Dynamic taint analysis device and application thereof to document format reverse analysis |
CN104375942A (en) * | 2014-12-11 | 2015-02-25 | 无锡江南计算技术研究所 | Binary oriented hybrid fuzzing method |
CN106021114A (en) * | 2016-06-02 | 2016-10-12 | 北京光年无限科技有限公司 | Automated testing method and system for intelligent robot |
Non-Patent Citations (4)
Title |
---|
D. KUNG 等: ""A reverse engineering approach for software testing of object-oriented programs"", 《PROCEEDINGS 1999 IEEE SYMPOSIUM ON APPLICATION-SPECIFIC SYSTEMS AND SOFTWARE ENGINEERING AND TECHNOLOGY》 * |
TEEMU KANSTREN 等: ""Using Reverse-Engineered Test-Based Models to Generate More Tests: Where is the Sense in That?"", 《2012 NINTH INTERNATIONAL CONFERENCE ON INFORMATION TECHNOLOGY - NEW GENERATIONS》 * |
汪春: ""基于事件流图的GUI自动化测试模型研究"", 《中国优秀硕士学位论文全文数据库 信息科技辑》 * |
王欢: ""静动态结合的安全漏洞检测方法研究"", 《中国优秀博硕士学位论文全文数据库(硕士)信息科技辑》 * |
Cited By (10)
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 |
CN112632992A (en) * | 2019-09-24 | 2021-04-09 | 北京京东振世信息技术有限公司 | Test method, test apparatus, computer device, and medium |
CN112632992B (en) * | 2019-09-24 | 2023-09-29 | 北京京东振世信息技术有限公司 | Test method, test device, computer equipment and medium |
CN111444094A (en) * | 2020-03-25 | 2020-07-24 | 中国邮政储蓄银行股份有限公司 | Test data generation method and system |
CN111382083A (en) * | 2020-04-30 | 2020-07-07 | 中国银行股份有限公司 | Test data generation method and device |
CN111382083B (en) * | 2020-04-30 | 2024-02-23 | 中国银行股份有限公司 | Test data generation method and device |
CN111813651A (en) * | 2020-05-28 | 2020-10-23 | 杭州览众数据科技有限公司 | Data abnormity testing method related to whole table structure and automatic testing tool |
CN111813651B (en) * | 2020-05-28 | 2023-07-04 | 杭州览众数据科技有限公司 | Data exception testing method and automatic testing tool related to whole-table structure |
CN112346989A (en) * | 2020-11-26 | 2021-02-09 | 网易(杭州)网络有限公司 | Interface testing method, device, medium and computing equipment |
CN112346989B (en) * | 2020-11-26 | 2023-06-20 | 网易(杭州)网络有限公司 | Interface testing method, device, medium and computing equipment |
Also Published As
Publication number | Publication date |
---|---|
CN109901987B (en) | 2022-07-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109901987A (en) | A kind of method and apparatus generating test data | |
CN109446099A (en) | Automatic test cases generation method, device, medium and electronic equipment | |
CN109697641A (en) | The method and apparatus for calculating commodity similarity | |
CN109254917B (en) | Method and apparatus for test data flow system | |
CN109871311A (en) | A kind of method and apparatus for recommending test case | |
CN109933514A (en) | A kind of data test method and apparatus | |
CN108776692A (en) | Method and apparatus for handling information | |
CN110471848A (en) | A kind of method and apparatus of dynamic returned packet | |
CN109727047A (en) | A kind of method and apparatus, data recommendation method and the device of determining data correlation degree | |
CN110119445A (en) | The method and apparatus for generating feature vector and text classification being carried out based on feature vector | |
CN107169077A (en) | Method and apparatus for pushed information | |
CN109976999A (en) | The measure and measurement apparatus of test case coverage rate | |
CN107341235A (en) | Report form inquiring method, device, medium and electronic equipment | |
CN109614327A (en) | Method and apparatus for output information | |
Stanimirović et al. | Decomposition of Catalan numbers and convex polygon triangulations | |
CN107783962A (en) | Method and device for query statement | |
CN109814957A (en) | A kind of label addition method and device for IOS system | |
CN110309142A (en) | The method and apparatus of regulation management | |
CN109960639A (en) | A kind of method and apparatus generating test case | |
CN110309293A (en) | Text recommended method and device | |
CN109960487A (en) | A kind of method and apparatus of extracting object | |
CN109753424A (en) | The method and apparatus of AB test | |
CN113989058A (en) | Service generation method and device | |
CN110084255A (en) | The detection method and device of abnormal data | |
CN109977982A (en) | User classification method, system, electronic equipment and computer-readable medium |
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 |