CN104636254B - Generate method and apparatus, method of testing and the equipment of test case - Google Patents

Generate method and apparatus, method of testing and the equipment of test case Download PDF

Info

Publication number
CN104636254B
CN104636254B CN201510024329.6A CN201510024329A CN104636254B CN 104636254 B CN104636254 B CN 104636254B CN 201510024329 A CN201510024329 A CN 201510024329A CN 104636254 B CN104636254 B CN 104636254B
Authority
CN
China
Prior art keywords
message
test
test case
mentioned
content
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
CN201510024329.6A
Other languages
Chinese (zh)
Other versions
CN104636254A (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.)
Newpoint Intelligent Technology Group Co ltd
Original Assignee
Innofidei 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 Innofidei Technology Co Ltd filed Critical Innofidei Technology Co Ltd
Priority to CN201510024329.6A priority Critical patent/CN104636254B/en
Publication of CN104636254A publication Critical patent/CN104636254A/en
Application granted granted Critical
Publication of CN104636254B publication Critical patent/CN104636254B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The embodiments of the invention provide a kind of method and apparatus, method of testing and equipment for generating test case, wherein the method for generation test case is specifically included:The data structure of message is defined according to the interface document of code to be measured, source template is generated;The configuration of message and message is listed in excel forms according to testing example design;The VBA scripts in the excel forms are called, the message and the copy of the source template are linked;The configuration file of the test case is generated according to the configuration of the message;The content of the message is filled in the copy of the source template.The embodiment of the present invention reduces the threshold and complexity of generation test case, so that shorten test case writes the time.

Description

Generate method and apparatus, method of testing and the equipment of test case
Technical field
The present invention relates to software testing technology field, more particularly to a kind of method for generating test case and a kind of generation The device of test case, a kind of test script client and a kind of method of testing.
Background technology
Unit testing be after the completion of software development, by developer according to Logic coverage, code coverage, initial value, face The conditions such as dividing value, desired value, write the test code to software code, to the correctness of inspection software code, so as to help Developer pinpoints the problems, improves software quality.
Unit test method relatively common at present has two kinds:One kind is pitching pile method, and it increases inspection in tested code Measuring point, monitors the operation result of tested code;Another is server/customer end model method, and it receives quilt in test lead The data that test code is sent, to monitor the implementation status of tested code;Wherein, server/customer end model method is relative The integrality of tested code can be kept in pitching pile method, thus is widely used.
Test case refers to the one group of test input developed for the specific objective of unit testing, execution condition and expected knot Really.At present the tester of test case is write when being tested not generally by tester is Lai artificial encoded test use-case Only need to understand the design principle of tested code, and also need to that tested code can be understood, therefore improve to tester The requirement of member's technical ability, this undoubtedly adds the time of writing.
Also, at present in the scheme of a variety of module testings, write test use again after the completion of tested code is write Example, and test case needs to refer to concrete implementation when being encoded with, this is easily caused the test case write and tested generation Code it is inconsistent, it is impossible to play well test effect.
The content of the invention
Technical problem to be solved of the embodiment of the present invention is to provide a kind of method for generating test case, reduces generation The threshold and complexity of test case, so that shorten test case writes the time.
Accordingly, the embodiment of the present invention additionally provides a kind of device for generating test case, a kind of test script client With a kind of method of testing, realization and application to ensure the above method.
In order to solve the above problems, the invention discloses a kind of method for generating test case, including:
The data structure of message is defined according to the interface document of code to be measured, source template is generated;
The configuration of message and message is listed in excel forms according to testing example design;
The VBA scripts in the excel forms are called, the message and the copy of the source template are linked;
The configuration file of the test case is generated according to the configuration of the message;
The content of the message is filled in the copy of the source template.
On the other hand, the invention also discloses a kind of device for generating test case, including:
Template generation module, the data structure for defining message according to the interface document of code to be measured generates message Template;
Message column goes out module, the configuration for listing message and message in excel forms according to testing example design;
Link module, for calling the VBA scripts in the excel forms, by the message and the source template Copy is linked;
File generating module, the configuration file for generating the test case according to the configuration of the message;And
Content fills in module, the content for filling in the message in the copy of the source template.
Another further aspect, the invention also discloses a kind of test script client, including:The dress of foregoing generation test case Put, connect and set up device, message conversion device, dispensing device, reception device and check device;
Wherein, the device of the generation test case, the configuration file for generating test case;Wherein, the configuration Chain of messages is connected to the copy of source template in file;
Device is set up in the connection, for setting up the connection with test agent server;
The message conversion device, the copy for reading the source template that message is linked in the configuration file, by it Be converted to message sequence;Wherein, the message sequence includes:Input message sequence and output message sequence;
The dispensing device, for sending the input message sequence to the test agent server;
The reception device, for receiving the test post content that the test agent server is returned;
The check device, for checking whether the test post content meets specified in the output message sequence Order, if so, then checking whether the test post content is consistent with the output message sequence, if so, then the test is used Example passes through, and otherwise the test case does not pass through.
Another aspect, the invention also discloses a kind of method of testing, applied to test script client, including:
Using the method for foregoing generation test case, the configuration file of test case is generated;Wherein, the configuration file Middle chain of messages is connected to the copy of source template;
Set up the connection with test agent server;
The copy of the source template that message is linked in the configuration file is read, message sequence is converted into;Wherein, institute Stating message sequence includes:Input message sequence and output message sequence;
The input message sequence is sent to the test agent server;
Receive the test post content that the test agent server is returned;
Check whether the test post content meets order specified in the output message sequence, if so, then checking Whether the test post content is consistent with the output message sequence, if so, then the test case passes through, it is otherwise described to survey Example on probation does not pass through.
Compared with prior art, the embodiment of the present invention includes advantages below:
The embodiment of the present invention, only need to be according to testing example design in excel forms during test case is write In list the configuration of message and message, and fill in the copy of source template the content of the message, it is possible to complete to survey Try out writing for example;Because the source template can be using the data interchange language for being easy to people's reading and writing, therefore the present invention is real Example is applied without excessive programming experience and to being tested the understanding of code, therefore reduces the threshold and complexity of generation test case Property, so that shorten test case writes the time;Also, the test case of the embodiment of the present invention depends only on interface text Shelves, therefore be separate with tested written in code, therefore code realization is will not depend upon, it is truly realized and realizes unrelated, increasing The strong validity of test.
Brief description of the drawings
Fig. 1 is a kind of step flow chart of the method for generation test case that the embodiment of the present application one is provided;
Fig. 2 is a kind of example of the message of test case defined in excel forms of the present invention;
Fig. 3 is a kind of step flow chart of the method for generation test case that the embodiment of the present application two is provided;
Fig. 4 is a kind of example of the message of test case defined in excel forms of the present invention;
Fig. 5 is the structure chart of the device embodiment one for the generation test case that the embodiment of the present application is provided;
Fig. 6 is the structure chart of the device embodiment two for the generation test case that the embodiment of the present application is provided;
Fig. 7 is the structure chart of the device embodiment three for the generation test case that the embodiment of the present application is provided;
Fig. 8 is the structure chart for the test system embodiment that the embodiment of the present application is provided;
Fig. 9 is the structure chart for the test script client embodiment that the embodiment of the present application is provided;
Figure 10 is the structure chart for the test agent server example that the embodiment of the present application is provided;
Figure 11 is the structure chart for the service unit 1001 that the embodiment of the present application is provided;
Figure 12 is the structure chart for the resolver 1002 that the embodiment of the present application is provided;
Figure 13 is a kind of flow chart for method of testing embodiment that the embodiment of the present application is provided;And
Figure 14 is a kind of flow chart for method of testing embodiment that the embodiment of the present application is provided.
Embodiment
In order to facilitate the understanding of the purposes, features and advantages of the present invention, it is below in conjunction with the accompanying drawings and specific real Applying mode, the present invention is further detailed explanation.
Generation method embodiment one
Reference picture 1, gives a kind of step flow chart of the method for generation test case of the offer of the embodiment of the present application one, Specifically it may include steps of:
Step 101, the data structure for defining according to the interface document of code to be measured message, generate source template;
The embodiment of the present invention can apply in unit testing, for shortening when writing of test case in unit testing Between, so as to reduce corresponding testing cost.
In unit testing, test case can specifically include:The test vector of one or more checkpoints, test vector Substantially it is made up of the configuration of message and message, and the data structure of message needed for test can be defined in interface document, therefore Can according to these corresponding source templates of data structure building test case, wherein, above-mentioned interface document generally falls into tested A part for the design documentation of code, above-mentioned generating process is used to being converted to interface document into the message mould for being easy to machine parsing Plate, above-mentioned source template can be using the language description for being easy to machine parsing.
In the specific implementation, interface document can be parsed, the data structure of acquisition corresponding message is simultaneously converted to standard The source template of JSON (JavaScript object representation, JavaScript Object Notation) form;Wherein, JSON Form is preferable data interchange language, had both been easy to people and has read and write, while being also easy to machine parsing and generating.
For example, in a kind of application example of the present invention, defined in interface document two message A_TO_B_MSG_1 and B_TO_A_MSG_2 and corresponding structure, then, the template of two message can be included in the source template of generation, with side Just step 102 two message defined in excel forms.
Step 102, the configuration that message and message are listed according to testing example design in excel forms;
Because test case refers to one group of test input, execution condition and the expection developed for the specific objective of unit testing As a result, therefore in a kind of application example of the present invention, it is above-mentioned according to testing example design listed in excel forms message and The step of configuration of message, it can specifically include:Message sequence (such as message 1, message 2 according to as defined in testing example design With message 3), the configuration of message and message is listed in excel forms.Specifically, input can be listed in excel forms to disappear The parameter of breath as input test vector, and list expect output message parameter as checkpoint.
Message or output message are either inputted, the parameter of above-mentioned message can specifically include one kind in following parameter Or it is a variety of:
1st, message name;
2nd, message direction;Input/output,
3rd, sequential;For input message, it is possible to specify at the time of the message is sent;For output message, it is possible to specify the phase Hope at the time of the message is sent or the period.
By taking above-mentioned two message A_TO_B_MSG_1 and B_TO_A_MSG_2 as an example, the embodiment of the present invention can be in excel Automatic setting includes the combobox of the message name of two message in form, then, tester only need to be in combobox Choose one and be used as message name.
Step 103, the VBA scripts called in above-mentioned excel forms, above-mentioned message and the copy of above-mentioned source template are entered Row link;
VBA (Visual Basic macrolanguages, Visual Basic for Applications) is Visual Basic A kind of macrolanguage, is that Microsoft develops the programming language that general automation task is performed in its multipad. In practical application, the VBA scripts in excel forms can be called to work, the message in above-mentioned excel forms is read and parse, And linked above-mentioned message and the copy of above-mentioned source template.The copy of above-mentioned source template namely above-mentioned source template Copy.
In a kind of alternative embodiment of the present invention, the above method can also include:Above-mentioned interface document is parsed, obtains each The mapping table of intermodule message to be measured, above-mentioned mapping table can be used in storage message name, message id (Identity) and message Hold the mapping relations between structure name.During writing test case in excel forms, tester is more desirable to Certain message is characterized by message name, rather than remembers the message id of this message, therefore it can be newly-built in excel forms This message, and by being provided with the message name of this message.So, step 103 is in above-mentioned excel forms are called During VBA scripts, the VBA scripts can be found in excel forms by inquiring about above-mentioned mapping table in the corresponding message of message name Hold structure file, so as to be this message relating to corresponding source template.The corresponding message id of message name also can be by simultaneously Preserve, used in the implementation procedure of test case, such as in the implementation procedure of test case can according to message id come Messaging.
Step 104, the configuration file for configuring the above-mentioned test case of generation according to above-mentioned message;
Above-mentioned configuration file specifically includes the test vector of above-mentioned message to perform in testing, and above-mentioned test vector can be with For JSON forms;Also, because step 102 only lists the parameter of message, the content without filling in message, therefore, this When configuration file be blank configuration file.
Run in the specific implementation, some VBA scripts can be developed in above-mentioned excel forms as grand, pin VBA Originally the test vector template of JSON forms can according to the message listed in excel, be automatically generated.
Reference picture 2, shows a kind of example of the message of test case defined in excel forms of the present invention, wherein, It can be arranged by writing the left side 5 in above-mentioned excel forms to define message and corresponding sequential, then call above-mentioned excel VBA scripts in form generate the corresponding empty configuration file of every message.
Step 105, the content for filling in the copy of above-mentioned source template above-mentioned message.
For input message, the content of message can include:The value of each field of message;For output message, message Content can include:The output valve of desired each field, it can also be provided that particular value makes script client not check this Field.After the content that input message and output message are filled in the copy of above-mentioned source template, it is possible to complete a test Use-case is write.;
To sum up, the embodiment of the present invention, only need to be according to testing example design in excel during test case is write The configuration of message and message is listed in form, and fills in the copy of source template the content of above-mentioned message, it is possible to be complete Into writing for test case;It is easy to the data interchange language that people reads and write because above-mentioned source template can be used, therefore this hair Bright embodiment without excessive programming experience and to being tested the understanding of code, therefore reduce generation test case threshold and Complexity, so that shorten test case writes the time;Also, the test case of the embodiment of the present invention depends only on interface Document, therefore be separate with tested written in code, therefore will not depend upon code realization, be truly realized realize it is unrelated, Enhance the validity of test.
Generation method embodiment two
Reference picture 3, gives a kind of step flow chart of the method for generation test case of the offer of the embodiment of the present application two, Specifically it may include steps of:
Step 301, the data structure for defining according to the interface document of code to be measured message, generate source template;
Step 302, the configuration that message and message are listed according to testing example design in excel forms;
Wherein, it is above-mentioned message and message are listed in excel forms according to testing example design configuration the step of, tool Body can include:
Sub-step 321, list according to the testing example design that subprocess includes in excel forms it is each described in disappear Breath, and the combination defined in excel forms between each subprocess, with by way of splicing by some sons Process is spliced into a complete test case;
Step 303, the VBA scripts called in above-mentioned excel forms, above-mentioned message and the copy of above-mentioned source template are entered Row link;
Step 304, the configuration file for configuring the above-mentioned test case of generation according to above-mentioned message;
Step 305, the content for filling in the copy of above-mentioned source template above-mentioned message.
In unit testing, in order to detect influence of the different parameters to code, it usually needs write some similar surveys Inevitably deposited between the subprocess of the test case similar with these between subprocess in example on probation, same test case In situation about repeating, that is, existing test case needs repeatedly to write the identical subprocess of similar test case.
The repetition sex chromosome mosaicism write for existing test case, the embodiment of the present invention during test case is write, Each message that subprocess is included only need to be listed in excel forms according to the testing example design, and in excel tables Combination defined in lattice between each subprocess, so that some subprocess are spliced into one by way of splicing Complete test case, that is, when writing test case, it is only necessary to write subprocess, and to these subprocess carry out groups Close, you can form complete test case, therefore solve the repetition sex chromosome mosaicism that test case is write, reduce generation test and use The workload of example.
There is provided herein and fill in an example of subprocess, specifically, can be referred in excel forms with above-mentioned source template Fixed form lists the sub-process name for needing to add successively, and starting and the terminating point of each subprocess are set respectively, and individually List the message content for needing to adjust.
Reference picture 4, shows a kind of example of the message of test case defined in excel forms of the present invention, wherein, The 5th in above-mentioned excel forms, 6,8 rows be used to represent subprocess and corresponding combination, the above-mentioned 5th, 6, the combination of 8 rows can spell A complete process is connected in, for tester, the corresponding row of subprocess is arranged in above-mentioned excel forms can be real The combination of existing subprocess.Wherein, the combination of subprocess can specifically include:Sequential concatenation mode and nested mode, etc..
To sum up, the present embodiment, which can be provided in excel forms, specifies some subprocess and the sequential between them to close The interface of system, it is possible to the message of above-mentioned excel forms middle finger sub-process is stitched together by certain rule automatically, as one Individual new test case, therefore the repetition sex chromosome mosaicism that test case is write is solved, reduce the workload of generation test case.
In addition, in a kind of alternative embodiment of the present invention, when splicing subprocess, can also allow for disappearing in sub-process The field of breath is adjusted, and makes the splicing of subprocess and has greater flexibility, and this causes tester realizing some bases Test case after, it is not necessary to write, only can just be realized greatly by the combination of subprocess in the basic test case again The extension use-case of amount.
Generation method embodiment three
The method of the generation test case of the present embodiment can be with the basis of above-mentioned embodiment illustrated in fig. 1, further Including following optional technical scheme.
Specifically, the above method of the present embodiment can also include:Enumeration type in above-mentioned interface document and grand Definition, the corresponding relation of enumeration type and macrodefinition and numerical value is stored to dictionary;
Then it is above-mentioned above-mentioned message is filled in the copy of above-mentioned source template content the step of, can specifically include:Make The content of above-mentioned message is filled in the enumeration type and macrodefinition in above-mentioned dictionary.
In the present embodiment, dictionary can be used for the corresponding relation for storing macrodefinition and numerical value, so, write test case When, the macrodefinition in above-mentioned dictionary can be directly used, without writing specific numerical value.For example, the span of certain field includes: 0 (CLOSE) and 1 (OPEN), when dictionary is not used, can write 0/1;And after using dictionary, can directly write CLOSE/ OPEN, thinks that more intuitive data are presented in tester.
To sum up, the present embodiment fills in test case using the enumeration type and macrodefinition in above-mentioned dictionary, can be test More intuitive data are presented in personnel.
It should be noted that for embodiment of the method, in order to be briefly described, therefore it to be all expressed as to a series of action group Close, but those skilled in the art should know, the embodiment of the present invention is not limited by described sequence of movement, because according to According to the embodiment of the present invention, some steps can be carried out sequentially or simultaneously using other.Secondly, those skilled in the art also should Know, embodiment described in this description belongs to preferred embodiment, the involved action not necessarily present invention is implemented Necessary to example.
The structure chart of the device embodiment one for the generation test case that reference picture 5 is provided there is provided the embodiment of the present application, tool Body can include:Template generation module 501, message column go out module 502, link module 503, file generating module 504 and content Fill in module 505;
Wherein, above-mentioned template generation module 501, the data knot for defining message according to the interface document of code to be measured Structure, generates source template;
Above-mentioned message column goes out module 502, for listing message and message in excel forms according to testing example design Configuration;
Above-mentioned link module 503, for calling the VBA scripts in above-mentioned excel forms, by above-mentioned message and above-mentioned message The copy of template is linked;
Above-mentioned file generating module 504, the configuration file for generating above-mentioned test case according to the configuration of above-mentioned message; And
The above fills in module 505, the content for filling in above-mentioned message in the copy of above-mentioned source template.
In a kind of alternative embodiment of the present invention, above-mentioned message column goes out module, specifically for according to the test case Design each message that subprocess is included, and each subprocess defined in excel forms are listed in excel forms Between combination, so that some subprocess are spliced into a complete test case by way of splicing, that is, When writing test case, it is only necessary to write subprocess, and these subprocess are combined, you can form complete test Use-case, therefore the repetition sex chromosome mosaicism that test case is write is solved, reduce the workload of generation test case
The present embodiment need to only be arranged during test case is write according to testing example design in excel forms The configuration of outbound message and message, and fill in the copy of source template the content of above-mentioned message, it is possible to complete test and use Example write;It is easy to the data interchange language that people reads and write because above-mentioned source template can be used, therefore the embodiment of the present invention Without excessive programming experience and to being tested the understanding of code, therefore reduce the threshold and complexity of generation test case, The time is write so as to shorten test case;Also, the test case of the embodiment of the present invention depends only on interface document, because This and tested written in code are separate, therefore will not depend upon code realization, are truly realized and realize unrelated, enhance survey The validity of examination.
The structure chart of the device embodiment two for the generation test case that reference picture 6 is provided there is provided the embodiment of the present application, tool Body can include:Template generation module 601, message column go out module 602, link module 603, file generating module 604, content and filled out Writing module 605 and mapping table acquisition module 606;
Wherein, above-mentioned template generation module 601, the data knot for defining message according to the interface document of code to be measured Structure, generates source template;Wherein, the multiple modules to be measured of the code correspondence to be measured;
Above-mentioned message column goes out module 602, for listing message and message in excel forms according to testing example design Configuration;
Above-mentioned mapping table acquisition module 606, for parsing above-mentioned interface document, obtains the mapping of each intermodule message to be measured Table, wherein, above-mentioned mapping table is used to store the mapping relations between message name, message id and message content structure name;
Above-mentioned link module 603, the corresponding message content knot of message in excel forms is obtained for inquiring about above-mentioned mapping table Structure body name, and be the corresponding source template of the above-mentioned message content structure name of above-mentioned message relating;
Above-mentioned file generating module 604, the configuration file for generating above-mentioned test case according to the configuration of above-mentioned message; And
The above fills in module 605, the content for filling in above-mentioned message in the copy of above-mentioned source template.
To sum up, the present embodiment is in the VBA scripts in calling above-mentioned excel forms, and the VBA scripts can be by inquiry State mapping table to find the corresponding message content structure file of message name in excel forms, so as to arrive for this message relating Corresponding source template, therefore, it is possible to rise to the convenience of above-mentioned message relating source template.
The structure chart of the device embodiment three for the generation test case that reference picture 7 is provided there is provided the embodiment of the present application, tool Body can include:Template generation module 701, message column go out module 702, link module 703, file generating module 704, content and filled out Writing module 705 and memory module 706 and dictionary 707;
Wherein, above-mentioned template generation module 701, the data knot for defining message according to the interface document of code to be measured Structure, generates source template;
Above-mentioned memory module 706, for the enumeration type and macrodefinition in the interface document, by enumeration type with The corresponding relation and macrodefinition of numerical value and the corresponding relation of numerical value are stored to above-mentioned dictionary 707;
Above-mentioned message column goes out module 702, for listing message and message in excel forms according to testing example design Configuration;
Above-mentioned link module 703, for calling the VBA scripts in above-mentioned excel forms, by above-mentioned message and above-mentioned message The copy of template is linked;
Above-mentioned file generating module 704, the configuration file for generating above-mentioned test case according to the configuration of above-mentioned message; And
The above fills in module 705, for the corresponding relation according to enumeration type in above-mentioned dictionary and numerical value and grand fixed Justice and the corresponding relation of numerical value, fill in the corresponding enumeration type of content or macrodefinition of the message.
The present embodiment fills in test case using the enumeration type and macrodefinition in above-mentioned dictionary, can be in for tester Existing more intuitive data.
For device embodiment, because it is substantially similar to embodiment of the method, so description is fairly simple, it is related Part illustrates referring to the part of embodiment of the method.
The structure chart for the test system embodiment that reference picture 8 is provided there is provided the embodiment of the present application, can specifically include: Test script client 801, test agent server 802 and tested code device 803;
Wherein, above-mentioned test script client 801 can be used for generation test case and implementation of test cases;
Above-mentioned test agent server 802 can be used for entering line number with test script client 801 and tested code device 803 According to interaction, and act on behalf of the test job that above-mentioned test script client completed and be tested code device 803;
Tested code device 803 is the target that software module testing needs to check, for given input, checks input knot Really, it passes through interacting message with the external world.
Above-mentioned test system can complete automatic test, therefore, it is possible to improve test according to the test case automatically generated Efficiency.
The structure chart for the test script client embodiment that reference picture 9 is provided there is provided the embodiment of the present application, specifically can be with Including:The device 901 of foregoing generation test case, connection set up device 902, message conversion device 903, dispensing device 904, Reception device 905 and check device 906;
Wherein, the device 901 of above-mentioned generation test case, the configuration file for generating test case;Wherein, it is above-mentioned to match somebody with somebody Put the copy that chain of messages in file is connected to source template;
Device 902 is set up in above-mentioned connection, for setting up the connection with test agent server;
Above-mentioned message conversion device 903, the copy for reading the source template that message is linked in above-mentioned configuration file will It is converted to message sequence;Wherein, above-mentioned message sequence can specifically include:Input message sequence and output message sequence;
Above-mentioned dispensing device 904, for sending above-mentioned input message sequence to above-mentioned test agent server;
Above-mentioned reception device 905, for receiving the test post content that above-mentioned test agent server is returned;
Above-mentioned check device 906, is advised for checking whether above-mentioned test post content meets in above-mentioned output message sequence Fixed order, if so, then checking whether above-mentioned test post content is consistent with above-mentioned output message sequence, if so, then above-mentioned survey Example on probation passes through, and otherwise above-mentioned test case does not pass through.
Above-mentioned test script client mainly has two functions:One it is automatic, efficiently generates test case, two is logical Cross and interacted with test agent server, perform the test case of above-mentioned generation.
In the specific implementation, above-mentioned test script client can be adjusted after the completion of test case is write by shortcut Worked with the VBA scripts in excel forms, and after having parsed whole data, initiate connection to test agent server and build Vertical request, starts the execution of a test case.
Specifically, it can set up SOCKET (socket) with test agent server and be connected.In the specific implementation, above-mentioned disappear Cease conversion equipment 903, can first read test vector, convert thereof into the form defined between test agent server, Corresponding data content (including message name, length, source module, purpose module, message time sequence, and message content etc.) is passed through SOCKET linkup transmits are to test agent server.
The structure chart for the test agent server example that reference picture 10 is provided there is provided the embodiment of the present application, specifically may be used With including:Service unit 1001 and resolver 1002;
Wherein, above-mentioned service unit 1001, data interaction, above-mentioned data interaction are carried out available for test script client It can specifically include:The data that above-mentioned test script client is sent are sent to above-mentioned resolver and are parsed and performed, And, the data that above-mentioned resolver has been handled are sent to above-mentioned test script client and checked;
Above-mentioned resolver 1002, obtains cycle tests, according to above-mentioned for parsing the data that above-mentioned service unit is sent The tested code device work of cycle tests simulation external environment condition driving, and, monitor the reception that above-mentioned tested code device is sent Message, after handling above-mentioned reception message, sends to above-mentioned service unit.
The structure chart for the service unit 1001 that reference picture 11 is provided there is provided the embodiment of the present application, can specifically include:
Module 1011 is monitored, for monitoring preset port, the connection of above-mentioned test script client is waited;
Wherein, above-mentioned preset port can be the port of test script client and test agent server commitment.
Receiving module 1012, for after the connection with above-mentioned test script client is set up, receiving above-mentioned test script The data that client is sent;
Calling module 1013, for when above-mentioned receiving module receives data success, calling above-mentioned resolver to enter line number According to processing;
Sending module 1014, for sending the result that above-mentioned resolver is returned to above-mentioned test script client;
Module 1015 is disconnected, for when above-mentioned receiving module receives data failure, disconnecting and above-mentioned test script client The connection at end.
In a kind of alternative embodiment of the present invention, above-mentioned service unit 1001 can also include:
Reset notification module, for after the connection with above-mentioned test script client is set up, calling above-mentioned tested code Device, which is performed, resets operation;
Then above-mentioned calling module 1013, can complete to disappear specifically for the reset returned in the above-mentioned test script client of reception After breath and the reception data success of above-mentioned receiving module, above-mentioned resolver is called to carry out the processing of data.
In actual applications, after first sets up connection inferior to test script client, new test process can be indicated Start, can now trigger above-mentioned reset notification module work.
The structure chart for the resolver 1002 that reference picture 12 is provided there is provided the embodiment of the present application, can specifically include:
Type of message parsing module 1021, for parsing data or the above-mentioned tested code device that above-mentioned service module is sent The type of the reception message sent, obtained type of message includes:Send message and receive message;
First processing module 1022, for for above-mentioned transmission message, judging whether current time reaches delivery time, such as Fruit reaches to be sent immediately, and the time of above-mentioned tested code device report is obtained until arriving by obstruction mode if not reaching Up to delivery time;If current time has exceeded delivery time, corresponding error code, finish test procedure are filled in;And
Second processing module 1023, for for the receive information with time correlation, whether judging the corresponding time of reception Correctly, data content and corresponding header are filled in if correct, fills in corresponding mistake in message header if incorrect Error code, data content and header and finish test procedure, if receiving data time-out, fill in corresponding error code, terminate to survey Examination process.
To sum up, the test agent server that the present invention is provided can enter line number with test script client and tested code device According to interaction, and the test job that above-mentioned test script client completed and be tested code device is acted on behalf of, above-mentioned interaction and agency are real Show the automatic test based on test case, improve testing efficiency.
A kind of flow chart for method of testing embodiment that reference picture 13 is provided there is provided the embodiment of the present application, it is applied to Test script client, can specifically include:
Step 1301, the method using foregoing generation test case, generate the configuration file of test case;Wherein, it is above-mentioned Chain of messages is connected to the copy of source template in configuration file;
Step 1302, foundation and the connection of test agent server;
Step 1303, the copy for reading the source template that message is linked in above-mentioned configuration file, are converted into message sequence Row;Wherein, above-mentioned message sequence is specifically included:Input message sequence and output message sequence;
Step 1304, to above-mentioned test agent server send above-mentioned input message sequence;
Step 1305, the test post content for receiving above-mentioned test agent server return;
Whether step 1306, the above-mentioned test post content of inspection meet order specified in above-mentioned output message sequence, if It is then to check whether above-mentioned test post content is consistent with above-mentioned output message sequence, if so, then above-mentioned test case passes through, Otherwise above-mentioned test case does not pass through.
The present embodiment be located at test script client end, both can automatically, efficiently generate test case, can pass through again With interacting for test agent server, the test case of above-mentioned generation is performed.
A kind of flow chart for method of testing embodiment that reference picture 14 is provided there is provided the embodiment of the present application, it is applied to Test agent server end, can specifically include:
Step 1401 and test script client carry out data interaction, and above-mentioned data interaction is specifically included:Receive above-mentioned survey The data that this client of training is sent, and, the reception message data handled is sent to above-mentioned test script client and entered Row is checked;
The data that step 1402, the above-mentioned test script client of parsing are sent obtain cycle tests, according to above-mentioned test sequence The tested code device work of row simulation external environment condition driving, and, the reception message that above-mentioned tested code device is sent is monitored, it is right Above-mentioned reception message is handled.
In a kind of alternative embodiment of the present invention, the step of above-mentioned and test script client carries out data interaction, tool Body can include:
Preset port is monitored, the connection of above-mentioned test script client is waited;
After the connection with above-mentioned test script client is set up, the data that above-mentioned test script client is sent are received;
When receiving data success, above-mentioned resolver is called to carry out the processing of data;
The result that above-mentioned resolver is returned is sent to above-mentioned test script client;
When receiving data failure, the connection with above-mentioned test script client is disconnected.
In another alternative embodiment of the present invention, the data that the above-mentioned above-mentioned test script client of parsing is sent are obtained Cycle tests, according to the tested code device work of above-mentioned cycle tests simulation external environment condition driving, and, monitor above-mentioned tested generation The reception message that code device is sent, the step of handling above-mentioned reception message can specifically include:
Parse the class of the data that above-mentioned test script client sends or the reception message that above-mentioned tested code device is sent Type, obtained type of message can specifically include:Send message and receive message;
For above-mentioned transmission message, judge whether current time reaches delivery time, sent immediately if reached, if do not had Have to reach and the time of above-mentioned tested code device report is then obtained until reaching delivery time by obstruction mode;If when current Exceed delivery time quarter, then fill in corresponding error code, finish test procedure;
For the receive information with time correlation, judge whether the corresponding time of reception is correct, number is filled in if correct According to content and corresponding header, corresponding error code, data content and header are filled in message header if incorrect And finish test procedure, if receiving data time-out, fill in corresponding error code, finish test procedure.
In another alternative embodiment of the present invention, the step of above-mentioned and test script client carries out data interaction, It can also include:
After the connection with above-mentioned test script client is set up, call above-mentioned tested code device to perform and reset operation;
After receiving the reset completion message of above-mentioned test script client return and receiving data success, above-mentioned solution is called Analysis apparatus carries out the processing of data
Each embodiment in this specification is described by the way of progressive, what each embodiment was stressed be with Between the difference of other embodiment, each embodiment identical similar part mutually referring to.
It should be understood by those skilled in the art that, the embodiment of the embodiment of the present invention can be provided as method, device or calculate Machine program product.Therefore, the embodiment of the present invention can using complete hardware embodiment, complete software embodiment or combine software and The form of the embodiment of hardware aspect.Moreover, the embodiment of the present invention can use it is one or more wherein include computer can With in the computer-usable storage medium (including but is not limited to magnetic disk storage, CD-ROM, optical memory etc.) of program code The form of the computer program product of implementation.
The embodiment of the present invention is with reference to method according to embodiments of the present invention, terminal device (system) and computer program The flow chart and/or block diagram of product is described.It should be understood that can be by computer program instructions implementation process figure and/or block diagram In each flow and/or square frame and the flow in flow chart and/or block diagram and/or the combination of square frame.These can be provided Computer program instructions are set to all-purpose computer, special-purpose computer, Embedded Processor or other programmable data processing terminals Standby processor is to produce a machine so that held by the processor of computer or other programmable data processing terminal equipments Capable instruction is produced for realizing in one flow of flow chart or multiple flows and/or one square frame of block diagram or multiple square frames The device for the function of specifying.
These computer program instructions, which may be alternatively stored in, can guide computer or other programmable data processing terminal equipments In the computer-readable memory worked in a specific way so that the instruction being stored in the computer-readable memory produces bag The manufacture of command device is included, the command device is realized in one flow of flow chart or multiple flows and/or one side of block diagram The function of being specified in frame or multiple square frames.
These computer program instructions can be also loaded into computer or other programmable data processing terminal equipments so that Series of operation steps is performed on computer or other programmable terminal equipments to produce computer implemented processing, so that The instruction performed on computer or other programmable terminal equipments is provided for realizing in one flow of flow chart or multiple flows And/or specified in one square frame of block diagram or multiple square frames function the step of.
Although having been described for the preferred embodiment of the embodiment of the present invention, those skilled in the art once know base This creative concept, then can make other change and modification to these embodiments.So, appended claims are intended to be construed to Including preferred embodiment and fall into having altered and changing for range of embodiment of the invention.
Finally, in addition it is also necessary to explanation, herein, such as first and second or the like relational terms be used merely to by One entity or operation make a distinction with another entity or operation, and not necessarily require or imply these entities or operation Between there is any this actual relation or order.Moreover, term " comprising ", "comprising" or its any other variant meaning Covering including for nonexcludability, so that process, method, article or terminal device including a series of key elements are not only wrapped Those key elements, but also other key elements including being not expressly set out are included, or also include being this process, method, article Or the intrinsic key element of terminal device.In the absence of more restrictions, by wanting that sentence "including a ..." is limited Element, it is not excluded that also there is other identical element in the process including the key element, method, article or terminal device.
Above to a kind of method for generating test case provided by the present invention and a kind of device of generation test case, one Test script client, a kind of test agent server and a kind of method of testing are planted, is described in detail, it is used herein Specific case is set forth to the principle and embodiment of the present invention, and the explanation of above example is only intended to help and understands this The method and its core concept of invention;Simultaneously for those of ordinary skill in the art, according to the thought of the present invention, specific It will change in embodiment and application, in summary, this specification content should not be construed as to the present invention's Limitation.

Claims (10)

1. a kind of method for generating test case, it is characterised in that including:
The data structure of message is defined according to the interface document of code to be measured, source template is generated;
The configuration of message and message is listed in excel forms according to testing example design, it is described to be listed in excel forms Message and message are configured to:Each message that subprocess is included is listed in excel forms, and it is fixed in excel forms Some subprocess are defined as a complete test case by the combination between each subprocess of justice;
The VBA scripts in the excel forms are called, the message and the copy of the source template are linked;
The configuration file of the test case is generated according to the configuration of the message;
The content of the message is filled in the copy of the source template.
2. according to the method described in claim 1, it is characterised in that it is described by some subprocess be defined as one it is complete The step of test case, including:So that some subprocess are spliced into a complete test case by way of splicing.
3. according to the method described in claim 1, it is characterised in that the message is filled in the copy of the source template Before content step, methods described also includes:Enumeration type and macrodefinition in the interface document, by enumeration type with The corresponding relation and macrodefinition of numerical value and the corresponding relation of numerical value are stored to dictionary;
Then it is described the message is filled in the copy of the source template content the step of, can specifically include:According to institute The corresponding relation and macrodefinition and the corresponding relation of numerical value of enumeration type and numerical value in dictionary are stated, the content of the message is filled in Corresponding enumeration type or macrodefinition.
4. according to the method described in claim 1, it is characterised in that the multiple modules to be measured of the code correspondence to be measured;
Then it is described call the excel forms in VBA scripts, the copy of the message and the source template is subjected to chain Before the step of connecing, methods described also includes:The interface document is parsed, the mapping table of each intermodule message to be measured is obtained, its In, the mapping table is used to store the mapping relations between message name, message id and message content structure name;
Then the VBA scripts called in the excel forms, the message and the copy of the source template are linked The step of, including:Inquire about the mapping table and obtain the corresponding message content structure name of message in excel forms, and be described The corresponding source template of message content structure name described in message relating.
5. a kind of device for generating test case, it is characterised in that including:
Template generation module, the data structure for defining message according to the interface document of code to be measured generates source template;
Message column goes out module, the configuration for listing message and message in excel forms according to testing example design, described Being configured to for message and message is listed in excel forms:Each message that subprocess is included is listed in excel forms, And the combination defined in excel forms between each subprocess, some subprocess are defined as one completely Test case;
Link module, for calling the VBA scripts in the excel forms, by the message and the copy of the source template Linked;
File generating module, the configuration file for generating the test case according to the configuration of the message;And
Content fills in module, the content for filling in the message in the copy of the source template.
6. device according to claim 5, it is characterised in that it is described by some subprocess be defined as one it is complete Test case, is specially so that some subprocess are spliced into a complete test case by way of splicing.
7. device according to claim 5, it is characterised in that also including memory module and dictionary:
The memory module, for the enumeration type and macrodefinition in the interface document, by enumeration type and numerical value The corresponding relation of corresponding relation and macrodefinition and numerical value is stored to the dictionary;
Then the content fills in module, specifically for the corresponding relation according to enumeration type in the dictionary and numerical value and grand fixed Justice and the corresponding relation of numerical value, fill in the corresponding enumeration type of content or macrodefinition of the message.
8. device according to claim 5, it is characterised in that the multiple modules to be measured of the code correspondence to be measured;
Then described device also includes:Mapping table acquisition module, for parsing the interface document, obtains each intermodule message to be measured Mapping table, wherein, the mapping that the mapping table is used to store between message name, message id and message content structure name is closed System;
Then the link module, the corresponding message content knot of message in excel forms is obtained specifically for inquiring about the mapping table Structure body name, and be the corresponding source template of message content structure name described in the message relating.
9. a kind of test script client, it is characterised in that including:Any described generation test in preceding claims 5 to 8 Device, message conversion device, dispensing device, reception device and check device are set up in the device of use-case, connection;
Wherein, the device of the generation test case, the configuration file for generating test case;Wherein, the configuration file Middle chain of messages is connected to the copy of source template;
Device is set up in the connection, for setting up the connection with test agent server;
The message conversion device, the copy for reading the source template that message is linked in the configuration file, is converted For message sequence;Wherein, the message sequence includes:Input message sequence and output message sequence;
The dispensing device, for sending the input message sequence to the test agent server;
The reception device, for receiving the test post content that the test agent server is returned;
The check device, for checking it is secondary specified in the output message sequence whether the test post content meets Sequence, if so, then checking whether the test post content is consistent with the output message sequence, if so, the then test case Pass through, otherwise the test case does not pass through.
10. a kind of method of testing, it is characterised in that applied to test script client, including:
Using the method for any described generation test case in preceding claims 1 to 4, the configuration text of test case is generated Part;Wherein, chain of messages is connected to the copy of source template in the configuration file;
Set up the connection with test agent server;
The copy of the source template that message is linked in the configuration file is read, message sequence is converted into;Wherein, it is described to disappear Breath sequence includes:Input message sequence and output message sequence;
The input message sequence is sent to the test agent server;
Receive the test post content that the test agent server is returned;
Check whether the test post content meets order specified in the output message sequence, if so, then checking described Whether test post content is consistent with the output message sequence, if so, then the test case passes through, the otherwise test is used Example does not pass through.
CN201510024329.6A 2015-01-16 2015-01-16 Generate method and apparatus, method of testing and the equipment of test case Active CN104636254B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510024329.6A CN104636254B (en) 2015-01-16 2015-01-16 Generate method and apparatus, method of testing and the equipment of test case

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510024329.6A CN104636254B (en) 2015-01-16 2015-01-16 Generate method and apparatus, method of testing and the equipment of test case

Publications (2)

Publication Number Publication Date
CN104636254A CN104636254A (en) 2015-05-20
CN104636254B true CN104636254B (en) 2017-07-28

Family

ID=53215038

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510024329.6A Active CN104636254B (en) 2015-01-16 2015-01-16 Generate method and apparatus, method of testing and the equipment of test case

Country Status (1)

Country Link
CN (1) CN104636254B (en)

Families Citing this family (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105260308A (en) * 2015-10-22 2016-01-20 南方科技大学 Method and device for testing Android terminal
CN105429982B (en) * 2015-11-20 2019-11-08 北京畅游天下网络技术有限公司 A kind of analysis method and device of client and server Content of Communication
CN105681126B (en) * 2015-12-30 2019-07-26 合一网络技术(北京)有限公司 A kind of automated testing method and system based on protocol interface
CN106980570B (en) * 2016-01-15 2021-04-13 创新先进技术有限公司 Test method and device
CN107133161B (en) * 2016-02-26 2021-03-05 中移动信息技术有限公司 Method and device for generating client performance test script
CN107168864A (en) * 2016-03-08 2017-09-15 上海大唐移动通信设备有限公司 Code stream generation method and device
CN105955887B (en) * 2016-05-04 2018-10-19 重庆长安汽车股份有限公司 A kind of generation method and system of test data
CN106919509B (en) * 2017-03-09 2020-11-24 腾讯科技(深圳)有限公司 Client generation method and device and electronic equipment
CN108829587A (en) * 2018-05-29 2018-11-16 平安普惠企业管理有限公司 Test case parameter replacing method, device, computer equipment and storage medium
CN109086199B (en) * 2018-06-22 2022-06-07 网宿科技股份有限公司 Method, terminal and storage medium for automatically generating test script
CN109050996A (en) * 2018-06-28 2018-12-21 上海卫星工程研究所 The instruction template generation method of satellite multi-mode complication system
CN109408375B (en) * 2018-09-27 2023-06-09 深圳壹账通智能科技有限公司 Method and device for generating interface document
CN109298861A (en) * 2018-10-19 2019-02-01 中国银行股份有限公司 A kind of method and device automatically generating file according to interface document
CN109634841B (en) * 2018-10-26 2024-03-12 平安科技(深圳)有限公司 Electronic device, interface automatic test method and storage medium
CN113169931B (en) * 2018-11-16 2023-03-24 利维帕尔森有限公司 Script-based automated robot program creation
CN110096434A (en) * 2019-03-28 2019-08-06 咪咕文化科技有限公司 Interface testing method and device
CN110334011B (en) * 2019-05-31 2023-03-17 浙江口碑网络技术有限公司 Method and device for executing test case
CN110287126A (en) * 2019-07-04 2019-09-27 上海睿赛德电子科技有限公司 A kind of unit testing frame suitable for embedded system
CN111177005B (en) * 2019-12-31 2024-04-16 中国银行股份有限公司 Service application testing method, device, server and storage medium
CN113849419B (en) * 2021-12-02 2022-04-05 上海燧原科技有限公司 Method, system, equipment and storage medium for generating test vector of chip
CN114756474B (en) * 2022-04-27 2023-07-21 苏州睿芯集成电路科技有限公司 Method and device for generating random vector in CPU verification and electronic equipment

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050060317A1 (en) * 2003-09-12 2005-03-17 Lott Christopher Martin Method and system for the specification of interface definitions and business rules and automatic generation of message validation and transformation software
CN100391290C (en) * 2005-01-14 2008-05-28 华为技术有限公司 Method of testing with integrated test tools
CN102508775A (en) * 2011-10-31 2012-06-20 彭勇 Interactive automation test system
CN103152216B (en) * 2011-12-07 2016-08-10 北京新媒传信科技有限公司 The method of testing of system and device in a kind of the Internet
CN103139822B (en) * 2013-03-27 2016-08-31 武汉邮电科学研究院 A kind of method that wireless communication system physical layer is carried out automatic test
CN103488482A (en) * 2013-09-16 2014-01-01 深圳市龙视传媒有限公司 Method and device for generating test cases

Also Published As

Publication number Publication date
CN104636254A (en) 2015-05-20

Similar Documents

Publication Publication Date Title
CN104636254B (en) Generate method and apparatus, method of testing and the equipment of test case
CN111159049B (en) Automatic interface testing method and system
CN106095673A (en) Automated testing method based on WEB interface and system
CN104797948B (en) Debugging in semiconducter device testing environment
CN105138461B (en) The interface test method and device of a kind of application program
CN104268079B (en) A kind of method and system of POS Application testings
CN102169846B (en) Method for writing multi-dimensional variable password in parallel in process of testing integrated circuit wafer
US10156611B2 (en) Executing code on a test instrument in response to an event
CN105117345B (en) The interface test method and device of a kind of application program
CN109766264A (en) Method of calibration, device, computer equipment and the storage medium of interface parameters
CN113190443A (en) Test method, test device, computer equipment and storage medium
CN107508720A (en) A kind of automated testing method and device
CN103678116B (en) For the method and system promoting automated procedures to test
CN109542780A (en) Test method, test equipment and the storage medium of natural language processing application
CN108628729A (en) A kind of method for testing software and software test client
CN105320593B (en) Multichannel frame random data authentication processing method and device
CN110554956B (en) BDMS automatic test method
CN106354643B (en) A kind of the accidental error test method and system of interactive software
CN110609786B (en) Software testing method, device, computer equipment and storage medium
KR101690948B1 (en) Method for verifying software using input output event scenario of time-line based aircraft apparatus and System thereof
WO2017092391A1 (en) Middle-tier database virtual control and testing method and system utilizing same
CN111190786A (en) UVM-based test framework, test platform and test method
CN110334014A (en) For user interface automated testing method, system, server and storage medium
CN112838938B (en) Test system of Internet of things platform
TWI266070B (en) Chip-level design under test verification environment and method thereof

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20191216

Address after: 353, block a, No.79, Jinyi Road, Xiaoshan Economic and Technological Development Zone, Xiaoshan District, Hangzhou City, Zhejiang Province

Patentee after: Newpoint Enterprise Management Group Co.,Ltd.

Address before: 100084 A, building 8, Tsinghua Science and Technology Park, No. 803, Zhongguancun East Road, building 1, Beijing, Haidian District

Patentee before: INNOFIDEI TECHNOLOGIES Inc.

CP01 Change in the name or title of a patent holder
CP01 Change in the name or title of a patent holder

Address after: 311200 353, block a, 79 Jinyi Road, Xiaoshan Economic and Technological Development Zone, Xiaoshan District, Hangzhou City, Zhejiang Province

Patentee after: Newpoint Intelligent Technology Group Co.,Ltd.

Address before: 311200 353, block a, 79 Jinyi Road, Xiaoshan Economic and Technological Development Zone, Xiaoshan District, Hangzhou City, Zhejiang Province

Patentee before: Newpoint Enterprise Management Group Co.,Ltd.