Summary of the invention
The embodiment of the invention is to provide a kind of mthods, systems and devices of test data batch generation, with test data batch generation at short notice, and simple to operate and guarantee the correctness of the data that generate.
The method of a kind of test data batch generation that the embodiment of the invention provides, comprise: template file is set, described template file comprises the original statement of test data to be generated, comprises the dynamic change part and the fixed value part of the test data of representing with variable in the described original statement; Described method also comprises: coordinate template parser, template compositor and file memory compounding practice by Data Generator, wherein,
Template parser is resolved described template file, discerns variable and fixed value part in the described template file;
The template compositor is according to the generating mode of described type of variables and described variable, generate real data, replace described variable with real data successively, generate the dynamic part of batch testing data, partly generate the static part of batch testing data according to described fixed value; The dynamic part and the static part that merge described test data generate test data in batches;
File memory stores the test data of described batch in the destination file into.
Wherein, described method also comprises: the batch testing data importing in the described destination file is existed in each related table in database.
Wherein, the generating mode of described variable comprises the mode increasing or decreasing with numerical value, with the mode increasing or decreasing of character, perhaps, is constituted and is had several values just to generate several records by a plurality of values.
The system of a kind of test data batch generation that the embodiment of the invention provides comprises:
Dispensing unit is used to be provided with template file, and described template file comprises the original statement of test data to be generated, comprises the dynamic change part and the fixed value part of the test data of representing with variable in the described original statement;
The test data generating apparatus is used to resolve described template file, discerns variable and fixed value part in the described template file; According to the generating mode of described type of variables and described variable, generate real data, replace described variable with real data successively, generate the dynamic part of batch testing data, partly generate the static part of batch testing data according to described fixed value; The dynamic part and the static part that merge described test data generate test data in batches; The test data of described batch is stored in the destination file.
Wherein, described system also comprises: import the unit, be used for the batch testing data importing of described destination file is existed in each related table in database.
Wherein, the generating mode of described variable comprises the mode increasing or decreasing with numerical value, with the mode increasing or decreasing of character, perhaps, is constituted and is had several values just to generate several records by a plurality of values.
The device of a kind of test data batch generation that the embodiment of the invention provides comprises:
Data Generator is used to coordinate template parser, template compositor and file memory compounding practice;
Template parser is used under the control of Data Generator, resolves the template file that has disposed, discerns variable and fixed value part in the described template file;
The template compositor, be used under the control of Data Generator, generating mode according to described type of variables and described variable, generate real data, replace described variable with real data successively, generate the dynamic part of batch testing data, partly generate the static part of batch testing data according to described fixed value; The dynamic part and the static part that merge described test data generate test data in batches;
File memory is used under the control of Data Generator, and the test data of described batch is stored in the destination file.
Wherein, the generating mode of described variable comprises the mode increasing or decreasing with numerical value, with the mode increasing or decreasing of character, perhaps, is constituted and is had several values just to generate several records by a plurality of values.
Use the present invention,, and can guarantee that the data that generate are correct, simultaneously, can handle the data of multilist association exactly even if a people who is ignorant of database also can generate the test data of a large amount of complexity in a short period of time.Not only improve work efficiency, and reduced the probability of makeing mistakes of test data.Use the mthods, systems and devices that the embodiment of the invention provides, simple, flexible, can create the data of any complexity, thereby satisfy various complicated service demands.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.
Referring to Fig. 1, it is the system architecture synoptic diagram according to the test data batch generation of the embodiment of the invention, and this system comprises:
Dispensing unit 101 is used to be provided with template file, and described template file comprises the original statement of test data to be generated, comprises the dynamic change part and the fixed value part of the test data of representing with variable in the described original statement.Described template file is arranged in the storeies such as hard disk of computing machine this locality.
Test data generating apparatus 102 is used to resolve described template file, discerns variable and fixed value part in the described template file; According to the generating mode of described type of variables and described variable, generate real data, replace described variable with real data successively, generate the dynamic part of batch testing data, partly generate the static part of batch testing data according to described fixed value; The dynamic part and the static part that merge described test data generate test data in batches; The test data of described batch is stored in the destination file.Described destination file is arranged in the storeies such as hard disk of computing machine this locality.
That is to say that operating personnel need write the template of the SQL statement that will generate by dispensing unit in template file, wherein need the field of dynamic change to represent with variable, and the field that need not change is partly represented with fixed value; Move the test data generating apparatus then, read template file automatically, and variable is wherein made an explanation, generate final SQL statement according to template by the test data generating apparatus; The last test data generating device is saved in the SQL statement that generates in the destination file.Present embodiment is to be that example describes with the SQL statement, can be the instrument in various editing datas storehouse in actual applications, and as PL, SQL or the like, the present invention does not limit the language of concrete use.
The system of above-mentioned test data batch generation can also comprise importing unit (figure does not show), is used for the batch testing data importing of described destination file is existed in each tables of data of incidence relation in database.For example, suppose to exist in the USER tables of data user name (NAME) and sign (ID) these two variablees, there are these two variablees of user name (NAME) and addresses of items of mail (EMAIL) in the USER ADDR tables of data, and user name (NAME) variable is identical in two tables, and USER tables of data and USER ADDR tables of data are exactly two tables that have incidence relation so.That is to say, can the SQL statement in the destination file directly be imported in the database by instruments such as PL/SQL.
The generating mode of above-mentioned variable includes but not limited to one of following three kinds of modes or combination in any:
Mode one, with the mode increasing or decreasing of numerical value, as radix is the value value, the each change procedure of the variable of the type is to increase by a fixed value or reduce by a fixed value on the basis of value, suppose that value is 10000, can be followed successively by 10001,10002 etc. after the each variation of variable;
Mode two, with the mode increasing or decreasing of character, as being " Zhang San " with character, radix is 0 for example, the each change procedure of the variable of the type is to allow the radix of having set increase by a fixed value or to reduce by a fixed value under the constant situation of character " Zhang San ", can be followed successively by " Zhang San 1 ", " Zhang San 2 " etc. as variable is each after changing;
Mode three, constitute by a plurality of values, there is several values just to generate several records, and can be nested, as a plurality of mailboxes that a user has same user name to name, a plurality of mailboxes herein are equivalent to a plurality of values, and user name itself is a variable, it can be nested among the mailbox, so just can generate many records, for example, for user name " Zhang San 1 ", the mailbox that can generate has many records such as " Zhang San 1@yahoo.cn ", " Zhang San 1@msn.com ".
Referring to Fig. 2, it is that it comprises according to the structural representation of the test data generating apparatus of the embodiment of the invention:
Data Generator (DataGenerator) 201 is used to coordinate template parser, template compositor and file memory compounding practice; That is to say that Data Generator is the inlet of whole device, be responsible for coordinating template parser, template compositor and file memory and finish test data generation task jointly.
Template parser (TemplateParser) 202 is used under the control of Data Generator, resolves the template file that has disposed, discerns variable and fixed value part in the described template file;
Template file is exactly a common text, has defined the original statement of test data, and dynamic part represents that with variable static part is represented with fixed value.Whole device just generates final test data according to this template file.
Template compositor (TemplateMerger) 203, be used under the control of Data Generator, generating mode according to described type of variables and described variable, generate real data, replace described variable with real data successively, generate the dynamic part of batch testing data, partly generate the static part of batch testing data according to described fixed value; The dynamic part and the static part that merge described test data generate test data in batches;
Above-mentioned, generate the process of True Data, just according to the type of variables of specifically having set and the generating mode of variable, the result who after the each variation of variable, obtains, for example, when being mode increasing or decreasing with numerical value for the generating mode of variable, when the value of radix value was 10000, the variable of the type changed True Data that the back generates at every turn and is followed successively by 10001,10002 etc.; Other variable generating mode no longer illustrates.
File memory (FileStorer) 204 is used under the control of Data Generator, the test data of described batch is stored into be arranged in local destination file.This this locality can be as storeies such as hard disks.
Destination file also is a common ground text, preserves the final test data that generates.These data can directly import in the database and use.
The generating mode of above-mentioned variable comprises the mode increasing or decreasing with numerical value, with the mode increasing or decreasing of character, perhaps, constitutes and has several values just to generate several records by a plurality of values, and can be nested.
Referring to Fig. 3, it is the process flow diagram according to the test data batch generation of the embodiment of the invention.
Step 1 is provided with template file, and described template file comprises the original statement of test data to be generated, comprises the dynamic change part and the fixed value part of the test data of representing with variable in the described original statement; In this example, template file is specific as follows, and wherein # represents the illustrative statement, the original statement of reality in the sql representation template file:
# inserts data in the USER table, id and name are variablees
sql.create.1=INSERT?INTO?USER(ID,NAME)VALUES({id},{name});
# increases data in the USER_ADDR table, id and email are variablees, and country is fixed value " China "
Sql.create.2=INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES ({ id}, " China ", { email});
First name of variables of three line displays is id below the #, and type is A, and value is 1000000.For the category-A variable, value increases progressively in the mode of numerical value, and radix is the value of value.
sql.param.1.name=id
sql.param.1.type=A
sql.param.1.value=1000000
Second name of variables of three line displays is name below the #, and type is B, be worth for " Zhang San ".For the category-B variable, value increases progressively in the mode of character, and radix is 0.
sql.param.2.name=name
sql.param.2.type=B
Sql.param.2.value=Zhang San
The 3rd name of variables of three line displays is email below the #, and type is C.For the C class variable, can comprise a plurality of values, have several values just to generate several records, and variable can be nested.
sql.param.3.name=email
sql.param.3.type=C
sql.param.3.value={name}@yahoo.cn,{name}@msn.com,{name}@alipay.com
# generates 8 groups of data
sql.num=8
Step 2~5, Data Generator receive the operation request, and the control template resolver begins operation, and described template parser is resolved described template file, discerns variable and fixed value part in the described template file; Concrete, template parser is obtained original statement from template file, and this original statement is resolved, thereby identifies variable and fixed value part in the template file.
Step 6, after parsing finishes to template file, Data Generator control template combiner begins operation, the template combiner is according to the generating mode of described type of variables and described variable, generate real data, replace described variable with real data successively, generate the dynamic part of batch testing data, partly generate the static part of batch testing data according to described fixed value; The dynamic part and the static part that merge described test data generate test data in batches;
The generating mode of described variable comprises the mode increasing or decreasing with numerical value, with the mode increasing or decreasing of character, perhaps, constitutes and has several values just to generate several records by a plurality of values, and can be nested.
Step 7~8, after the generation test data in batches, Data Generator control documents storer begins operation, and file memory stores the test data of described batch in the destination file into.
At aforementioned template file, the test data that is generated is as follows:
INSERT INTO USER (ID, NAME) VALUES (1000000, ' Zhang San 0 ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 0@yahoo.cn ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 0@msn.com ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 0@alipay.com ');
INSERT INTO USER (ID, NAME) VALUES (1000001, ' Zhang San 1 ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 1@yahoo.cn ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 1@msn.com ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 1@alipay.com ');
INSERT INTO USER (ID, NAME) VALUES (1000002, ' Zhang San 2 ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 2@yahoo.cn ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 2@msn.com ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 2@alipay.com ');
INSERT INTO USER (ID, NAME) VALUES (1000003, ' Zhang San 3 ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 3@yahoo.cn ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 3@msn.com ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 3@alipay.com ');
INSERT INTO USER (ID, NAME) VALUES (1000004, ' Zhang San 4 ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 4@yahoo.cn ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 4@msn.com ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 4@alipay.com ');
INSERT INTO USER (ID, NAME) VALUES (1000005, ' Zhang San 5 ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 5@yahoo.cn ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 5@msn.com ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 5@alipay.com ');
INSERT INTO USER (ID, NAME) VALUES (1000006, ' Zhang San 6 ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 6@yahoo.cn ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 6@msn.com ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 6@alipay.com ');
INSERT INTO USER (ID, NAME) VALUES (1000007, ' Zhang San 7 ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 7@yahoo.cn ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 7@msn.com ');
INSERT INTO USER_ADDR (ID, COUNTRY, EMAIL) VALUES (1000000, ' China ', ' Zhang San 7@alipay.com ');
commit;
So far, generated 8 groups of test datas, finished the generating run of batch testing data according to the template file that disposes above.4 every group of above-mentioned batch testing data, wherein 1 is the data that the master meter data are promptly shown at USER, all the other 3 is the data that exist related contingency table data promptly to show at USER_ADDR with the USER table.
Can also comprise after this:
There is the batch testing data importing in the described destination file in each tables of data of incidence relation in step 9 in database.
Use mthods, systems and devices provided by the invention, even if a people who is ignorant of database also can generate the test data of a large amount of complexity in a short period of time, and can guarantee that the data that generate are correct, simultaneously, can handle the data of multilist association exactly.Not only improve work efficiency, and reduced the probability of makeing mistakes of test data.Use the mthods, systems and devices that the embodiment of the invention provides, simple, flexible, can create the data of any complexity, thereby satisfy various complicated service demands.
One of ordinary skill in the art will appreciate that all or part of step that realizes in the said method embodiment is to instruct relevant hardware to finish by program, described program can be stored in the computer read/write memory medium, here the alleged storage medium that gets, as: ROM/RAM, magnetic disc, CD etc.
The above is preferred embodiment of the present invention only, is not to be used to limit protection scope of the present invention.All any modifications of being done within the spirit and principles in the present invention, be equal to replacement, improvement etc., all be included in protection scope of the present invention.