Summary of the invention
In view of the above problems, it proposes on the present invention overcomes the above problem or at least be partially solved in order to provide one kind
State the test case dynamic state of parameters configuration method and device of problem.
One side according to the present invention provides a kind of test case dynamic state of parameters configuration method, comprising:
Test case parameter is obtained from multiple preparatory XML files for describing to have test case parameter;
Test case parameter based on acquisition constructs parameter set, and the parameter set of building is stored to the preset parameter collection list
In, wherein the corresponding test case parameter of a test case constructs a parameter set;
The target detection example that user chooses is received, it is right with the target detection example to search from the preset parameter collection list
The parameter set answered;
Corresponding parameter configuration interface is generated according to the dynamic state of parameters in the parameter set found, passes through the parameter configuration
Interface receives and reconfigures to the target detection example parameter;
The content in the corresponding XML file of the target detection example is updated based on the parameter reconfigured.
Optionally, each parameter set in the preset parameter collection list is identified with the unique identification of corresponding test case, described
The target detection example that user chooses is received, parameter corresponding with the target detection example is searched from the preset parameter collection list
Collection, comprising:
The target detection example that user chooses is received, the unique identification of the target detection example is obtained;
Parameter set corresponding with the unique identification of the target detection example is searched from preset parameter collection list.
Optionally, it before obtaining test case parameter in multiple preparatory XML files for describing to have test case parameter, also wraps
It includes: the multiple preparatory XML files for describing to have test case parameter of load.
Optionally, multiple preparatory XML files for describing to have test case parameter are loaded, comprising:
The TestScript file under test program catalogue is searched, from the next stage catalogue of TestScript file
Traverse different test scene files, wherein be previously stored with the XML file in the test scene file;
The corresponding XML file of different test cases is loaded from each test scene file.
Optionally, the parameter in the parameter set includes displaying sequence, the parameter in parameter set that the foundation is found
The corresponding parameter configuration interface of dynamic generation, comprising:
According to displaying sequence, the corresponding ginseng of each test case parameter in the parameter set found is shown in displaying control
Number configuration control, the corresponding parameter configuration interface of parameter configuration control dynamic generation based on displaying.
Optionally, the content in the corresponding XML file of the target detection example is updated based on the parameter reconfigured, wrapped
It includes:
The corresponding parameter set of target detection example in the preset parameter collection list is carried out more using the parameter reconfigured
Newly;
The content in corresponding XML file is updated according to the corresponding updated parameter set of target detection example.
Optionally, the method also includes: tool is executed by test case by reconfiguring the target detection example after parameter
Ranging sequence is treated to be tested.
Optionally, tool is executed by reconfiguring the target detection example after parameter by test case treat ranging sequence surveyed
Examination, comprising:
Corresponding pre-defined of tool matching is executed by test case by reconfiguring the target detection example after parameter
Test case encoder;
The test case parameter in the corresponding updated XML file of the target detection example is read, successful match is utilized
Test case encoder is encoded according to test case parameter of the preset protocol to reading and generates protocol data;
The protocol data is sent in program to be measured, the program to be measured is tested.
Optionally, corresponding pre- of tool matching is executed by test case by reconfiguring the target detection example after parameter
The test case encoder first defined, comprising:
Passed through the test case and executed tool by reconfiguring the target detection example after parameter and calls corresponding test letter
Number, wherein define test template in the formal parameter of the test function;
Test function based on calling obtains corresponding test template, and the type matching according to the test template is fixed in advance
The test case encoder of justice.
Another aspect according to the present invention additionally provides a kind of test case dynamic state of parameters configuration device, comprising:
Module is obtained, suitable for obtaining test case parameter from multiple preparatory XML files for describing to have test case parameter;
Module is constructed, parameter set is constructed suitable for the test case parameter based on acquisition, the parameter set of building is stored to described
In preset parameter collection list, wherein the corresponding test case parameter of a test case constructs a parameter set;
Receiving module, the target detection example chosen suitable for receiving user, lookup and institute from the preset parameter collection list
State the corresponding parameter set of target detection example;
Generation module leads to suitable for generating corresponding parameter configuration interface according to the dynamic state of parameters in the parameter set found
The parameter configuration interface reception is crossed to reconfigure the target detection example parameter;
Update module, suitable for being updated based on the parameter reconfigured in the corresponding XML file of the target detection example
Hold.
In embodiments of the present invention, by obtaining test case from multiple preparatory XML files for describing to have test case parameter
Parameter, and the test case parameter based on acquisition constructs parameter set, and the parameter set of building is stored into preset parameter collection list,
With after the target detection example for receiving user's selection, it is right with target detection example to search directly from preset parameter collection list
The parameter set answered.Then, corresponding ginseng is generated according to the dynamic state of parameters in the parameter set corresponding with target detection example found
Number configuration interface.User can reconfigure target detection example parameter by parameter configuration interface, and then can be based on
The parameter reconfigured updates the content in the corresponding XML file of target detection example.The embodiment of the present invention is by being based on as a result,
XML file describes test case parameter, and generates corresponding parameter configuration interface according to test case parameter, so as to directly pass through
Parameter configuration interface is adjusted test case parameter, to modified in XML file based on the test case parameter of adjustment
Hold, such as increase, modification, deletion to parameter, it is not necessary to modify the codes in test program at all for the process, and parameter adjusted
Journey is simple, convenient, not only improves regulating the speed for test case parameter, can also support the multiplexing to test case parameter, has pole
High flexibility and scalability.
Further, this programme stores parameter set into preset parameter collection list, when it is subsequent using test case parameter or
When person's parameter set, can directly it be obtained from the preset parameter collection list, without traversing the content in each XML file,
So as to improve the acquisition efficiency of test case parameter.
The above description is only an overview of the technical scheme of the present invention, in order to better understand the technical means of the present invention,
And it can be implemented in accordance with the contents of the specification, and in order to allow above and other objects of the present invention, feature and advantage can
It is clearer and more comprehensible, the followings are specific embodiments of the present invention.
According to the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will be brighter
The above and other objects, advantages and features of the present invention.
Specific embodiment
Exemplary embodiments of the present disclosure are described in more detail below with reference to accompanying drawings.Although showing the disclosure in attached drawing
Exemplary embodiment, it being understood, however, that may be realized in various forms the disclosure without should be by embodiments set forth here
It is limited.On the contrary, these embodiments are provided to facilitate a more thoroughly understanding of the present invention, and can be by the scope of the present disclosure
It is fully disclosed to those skilled in the art.
In order to solve the above technical problems, the embodiment of the invention provides a kind of test case dynamic state of parameters configuration method, the party
Method can be applied to the Dynamic Configuration Process that the test case based on TTCN3 language carries out test case parameter.Fig. 1 is shown according to this
The flow diagram of the test case dynamic state of parameters configuration method of invention one embodiment.Referring to Fig. 1, this method includes at least step
S102 to step S110.
Step S102 obtains test case parameter from multiple preparatory XML files for describing to have test case parameter.
The step is based on XML file and describes test parameter, can be facilitated by the node in modification XML file subsequent
Adjustment of the realization to test case parameter.
Step S104, the test case parameter based on acquisition construct parameter set, the parameter set of building are stored to preset parameter
Collect in list, wherein the corresponding test case parameter of a test case constructs a parameter set.
Step S106 receives the target detection example that user chooses, searches and target detection example from preset parameter collection list
Corresponding parameter set.
In this step, each parameter set in the list of preset parameter collection is identified with the unique identification of corresponding test case, from
When searching parameter set corresponding with target detection example in preset parameter collection list, unique mark of target detection example can be first obtained
Know, and then searches parameter set corresponding with the unique identification of target detection example from preset parameter collection list.
Step S108 generates corresponding parameter configuration interface according to the dynamic state of parameters in the parameter set found, passes through ginseng
Number configuration interface reception reconfigures target detection example parameter.
It in this step, may include increase, deletion, modification etc. to parameter to reconfiguring for target detection example parameter
Configuration operation.
Step S110 updates the content in the corresponding XML file of target detection example based on the parameter reconfigured.
In this step, when updating the content in the corresponding XML file of target detection example based on the parameter reconfigured, tool
Body can be updated the corresponding parameter set of target detection example in preset parameter collection list first with the parameter reconfigured, into
And the content in corresponding XML file is updated according to the corresponding updated parameter set of target detection example.
The embodiment of the present invention describes test case parameter by being based on XML file, and corresponding according to the generation of test case parameter
Parameter configuration interface, so as to be directly adjusted by parameter configuration interface to test case parameter, thus based on adjustment
Test case parameter modifies the content in XML file, such as increase, modification, deletion to parameter, the process at all it is not necessary to modify
Code in test program, and parameter tuning process is simple, convenient not only improves regulating the speed for test case parameter, can be with
It supports the multiplexing to test case parameter, there is high flexibility and scalability.Further, this programme by parameter set store to
It, can be directly from the preset parameter collection list when subsequent use test case parameter or parameter set in preset parameter collection list
Middle acquisition, without traversing the content in each XML file, so as to improve the acquisition efficiency of test case parameter.
Step S102 is seen above, in an embodiment of the present invention, from multiple preparatory XML texts for describing to have test case parameter
When obtaining test case parameter in part, it is also necessary to first load it is multiple it is preparatory describe have the XML files of test case parameter, and then from load
XML file in obtain test case parameter.Referring to fig. 2, preparatory descriptions multiple to load below have the XML files of test case parameter
And the process of acquisition test case parameter is introduced.
Step S202, the TestScript file under test program catalogue is searched.Test program is i.e. current to execute program.
Step S204, different test scene files are traversed from the next stage catalogue of TestScript file, wherein
The XML file that description in advance has test case parameter is housed in test scene file.
Step S206, the corresponding XML file of different test cases being successively read in test scene file.
Since this programme can read the XML configuration file in different test scenes, the survey based on this programme exploitation
Test program in examination software can support the test of more scrnario testing modes.
Step S208, the format of the XML file read is verified, and judges whether to be proved to be successful, if so, holding
Row step S210, if it is not, thening follow the steps S206.
In this step, the verification information content verified to the format of XML file is set in advance in XML file.
Verification information may include the relevant verification information such as the type of test case parameter, range in XML file.
Step S210, test case parameter is obtained from the XML file read.
Step S212, judge whether to complete the reading to whole XML files under different test scene files, if so,
Terminate, if it is not, thening follow the steps S206.
In conjunction with above step S104, the corresponding test case parameter of a test case is had been described above above and constructs a parameter
Collection.In this embodiment, test case parameter is obtained from the XML file read, the test case parameter based on acquisition constructs ginseng
Manifold, and the process that parameter set is stored to preset parameter collection list can be such that and circuit sequentially owning in traversal XML file
Attribute in every a line node in XML file is stored in corresponding parameter set structural body, then by parameter set structure by node
Body is inserted into parameter set list predetermined.
The XML file of the embodiment of the present invention can use the structure type of hierarchical tree, file beginning setting file explanation
Sentence is used for supporting paper version number and coding mode.Followed by root node params parameter set, it is after root node
Param parameter child node, param have 14 attributes, including id unique identification, order displaying sequence, name parameter name,
Title parameter display title, value parameter value, selectValue selective value, defaultValue default value, unit unit,
Whether type control type, enable can operate, and whether visible shows, min minimum value, max maximum value, hint prompt letter
Breath.Wherein, in type control type include input input frame, select drop-down list box, table pop up three kinds of table, be used for
Different types of exhibition method is provided.Test case configuration parameter is constructed using XML file, parameter and program can be effectively realized
Separation, the content in XML file need to be only modified when modifying test case parameter, it is not necessary to modify program codes.
One embodiment of the invention provides the partial content of an XML file, as follows:
Step S106 is seen above, in an embodiment of the present invention, according to the dynamic state of parameters in the parameter set found
It, can be according to the order displaying sequence in parameter set, in (such as Grid control of display control when generating corresponding parameter configuration interface
Part) in show the corresponding parameter configuration control of each test case parameter, parameter configuration control be used for corresponding test case parameter into
Row configuration, thus the corresponding parameter configuration interface of parameter configuration control dynamic generation based on displaying.Utilize the ginseng in parameter set
Number dynamic generation parameter configuration interface is also the initialization procedure to display control, as according to test case parameter to control is shown
The contents such as title, display order, type, default value are initialized.
In this embodiment, being also possible in the list of preset parameter collection can be comprising the parameter of some defaults, and user can not be to it
It modifies.Therefore, it is also desirable to determine that the parameter of default includes by each parameter set in traversal preset parameter collection list
Visible is display " true ", does not still show " false ".
If visible is " false ", directly skip, and searches the visible of next parameter set until preset parameter
Collect the last one parameter set in list.If visible is " true ", it is dynamically inserted into a line in GRID (display control),
Wherein, first it is classified as hiding id value, second is classified as title title, and third is classified as the codomain of parameter, and the 4th is classified as unit unit
Value.Wherein, codomain control is initialized according to type value, tpye is the input frame that " input " control is default, and tpye is
" select " control is dynamic creation drop-down list box, and tpye is " table " control to be inserted into button, for example, if tpye is
" select " then can fill drop-down list option using the value of selectValue.
In turn, " value " can also be read with the codomain of pad parameter, read " enable ", if read
" enable " is " false ", then the codomain after pad parameter will be set as modifying.
In an embodiment of the present invention, it is being updated in the corresponding XML file of target detection example based on the parameter reconfigured
Content after, can use the target detection example after reconfiguring parameter by test case execute tool treat ranging sequence carry out
Test.Specific test process is:
Firstly, executing corresponding preparatory of tool matching by test case by reconfiguring the target detection example after parameter
Fixed test case encoder.
Then, the test case parameter in the corresponding updated XML file of target detection example is read, successful match is utilized
Test case encoder is encoded according to test case parameter of the preset protocol to reading and generates protocol data.
Finally, protocol data is sent in program to be measured, treats ranging sequence and tested.
In this embodiment, using reconfigure the target detection example after parameter by test case execute tool matching and
When its corresponding test case encoder predetermined, it can be held by reconfiguring the target detection example after parameter by test case
Row tool calls corresponding test function, wherein defines test template in the formal parameter of test function.And then based on tune
Test function obtains corresponding test template, the type matching test case encoder predetermined according to test template.
The process of program to be measured is tested to more clearly embody the present invention using the test case after reconfiguring parameter,
It is specifically introduced below with an embodiment.For example, target detection example is the test case designed based on TTCN, also, mention herein
And TTCN test case refer to reconfiguring the test case after parameter.
The first step, user, which click, to be started to execute test program, starts TTCN test case.
Second step, TTCN test case call corresponding test function (test function), join in the form of function
It is defined in number template (test template), according to template type matching encoder predetermined.
Third step, the ID for obtaining test case, it is right therewith that the ID according to test case is found from different document scene folders
The updated XML file answered.Wherein, not only description has test case parameter in XML file, but also including for recognizing which being
The ID of the parameter of one test case is identified.
4th step, traversal XML file in each node parameter, parameter name name and parameter value value are put into
In dictionary.
Content in 5th step, reading dictionary, encoder carry out the content of reading according to the requirement of preset protocol format
It encodes and generates protocol data.
6th step, encoder send the protocol data after encoding into program to be measured, are tested with treating ranging sequence.
7th step, the feedback information for receiving program to be measured, call corresponding test function, according in function
Template type matching decoder predetermined, to be decoded to feedback information.
For example, the feedback information returned includes test crash, the identification informations such as is successfully tested, needs to retest.
The parameter reconfigured can also be uniformly converted to dictionary key/value, such as name/ by the embodiment of the present invention
The unification of interface may be implemented in the form of value, improves the expansion and flexibility of software.This programme does not have to modification software journey
The quick exploitation of test case parameter configuration can be realized in sequence, in the profession using TTCN3 language development protocol measure metering device
On the basis of property, the scalability and versatility of software in metering device are improved.In addition, different test scenes need to only configure difference
XML file, only one version of software, unified software version substantially increase in measuring instrumentss device the research and development of software and
Maintenance efficiency.
In addition, if the embodiment of the present invention is based on TTCN3 language development test case, can with supported protocol consistency, it is parallel,
The test of time delay etc., while can also support graphical representation test process, the transmitting-receiving of each protocol interaction is believed in the process
Breath can intuitively be shown compared with judgement.
Based on the same inventive concept, the embodiment of the invention also provides a kind of test case dynamic state of parameters configuration device, Fig. 3 shows
The structural schematic diagram of test case dynamic state of parameters configuration device according to an embodiment of the invention is gone out.Referring to Fig. 3, test case ginseng
Number dynamic configuration devices 400 include at least obtain module 410, building module 420, receiving module 430, generation module 440 and
Update module 450.
Now introduce the function of each composition or device based on test case dynamic state of parameters configuration device 400 of the embodiment of the present invention
And the connection relationship between each section:
Module 410 is obtained, suitable for obtaining test case parameter from multiple preparatory XML files for describing to have test case parameter;
Module 420 is constructed, is coupled with module 410 is obtained, parameter set is constructed suitable for the test case parameter based on acquisition, by structure
The parameter set built is stored into preset parameter collection list, wherein the corresponding test case parameter of a test case constructs a parameter
Collection;
Receiving module 430, couples with building module 420, the target detection example chosen suitable for receiving user, from preset parameter
Collect and searches parameter set corresponding with target detection example in list;
Generation module 440 is coupled with receiving module 430, suitable for generating according to the dynamic state of parameters in the parameter set found
Corresponding parameter configuration interface reconfigures target detection example parameter by parameter configuration interface reception;
Update module 450 is coupled with generation module 440, right suitable for updating target detection example based on the parameter reconfigured
The content in XML file answered.
In an embodiment of the present invention, if each parameter set in preset parameter collection list is identified with the unique of corresponding test case
Mark receives the target detection example that user chooses, and receiving module 430 is further adapted for, and receives the target detection example that user chooses, and obtains
The unique identification of target detection example searches parameter corresponding with the unique identification of target detection example from preset parameter collection list
Collection.
In an embodiment of the present invention, if the parameter in parameter set includes displaying sequence, generation module 440 is further adapted for foundation
The displaying sequence of parameter identification, shows the corresponding parameter configuration control of each test case parameter, base in displaying control in parameter set
In the corresponding parameter configuration interface of parameter configuration control dynamic generation of displaying.
In an embodiment of the present invention, update module 450 is further adapted for, and is arranged using the parameter reconfigured preset parameter collection
The corresponding parameter set of target detection example is updated in table, is updated according to the corresponding updated parameter set of target detection example corresponding
XML file in content.
In an embodiment of the present invention, referring to fig. 4, test case dynamic state of parameters configuration device 400 is in addition to including above-mentioned module
Except, it can also include loading module 460 and test module 470.
Loading module 460 is coupled with module 410 is obtained, suitable for having test case from multiple preparatory descriptions in acquisition module 410
Before obtaining test case parameter in the XML file of parameter, multiple preparatory XML files for describing to have test case parameter are loaded.
Test module 470 is coupled with update module 450, suitable for passing through survey by reconfiguring the target detection example after parameter
Examination example execution tool is treated ranging sequence and is tested.
In an embodiment of the present invention, loading module 460 is further adapted for, and searches the TestScript text under test program catalogue
Part folder, traverses different test scene files, wherein test scene file from the next stage catalogue of TestScript file
It is previously stored with XML file in folder, the corresponding XML file of different test cases is loaded from each test scene file.
In an embodiment of the present invention, test module 470 is further adapted for, and is passed through by reconfiguring the target detection example after parameter
Test case executes the corresponding test case encoder predetermined of tool matching, after reading the corresponding update of target detection example
XML file in test case parameter, using the test case encoder of successful match according to preset protocol to the test case of reading
Parameter is encoded and is generated protocol data, and protocol data is sent in program to be measured, is treated ranging sequence and is tested.
In an embodiment of the present invention, test module 470 is further adapted for, and is passed through by reconfiguring the target detection example after parameter
Test case executes tool and calls corresponding test function, wherein test template, base are defined in the formal parameter of test function
Corresponding test template is obtained in the test function of calling, the test case coding predetermined of the type matching according to test template
Device.
According to the combination of any one above-mentioned preferred embodiment or multiple preferred embodiments, the embodiment of the present invention can reach
It is following the utility model has the advantages that
In embodiments of the present invention, by obtaining test case from multiple preparatory XML files for describing to have test case parameter
Parameter, and the test case parameter based on acquisition constructs parameter set, and the parameter set of building is stored into preset parameter collection list,
With after the target detection example for receiving user's selection, it is right with target detection example to search directly from preset parameter collection list
The parameter set answered.Then, corresponding ginseng is generated according to the dynamic state of parameters in the parameter set corresponding with target detection example found
Number configuration interface.User can reconfigure target detection example parameter by parameter configuration interface, and then can be based on
The parameter reconfigured updates the content in the corresponding XML file of target detection example.The embodiment of the present invention is by being based on as a result,
XML file describes test case parameter, and generates corresponding parameter configuration interface according to test case parameter, so as to directly pass through
Parameter configuration interface is adjusted test case parameter, to modified in XML file based on the test case parameter of adjustment
Hold, such as increase, modification, deletion to parameter, it is not necessary to modify the codes in test program at all for the process, and parameter adjusted
Journey is simple, convenient, not only improves regulating the speed for test case parameter, can also support the multiplexing to test case parameter, has pole
High flexibility and scalability.Further, this programme stores parameter set into preset parameter collection list, uses survey when subsequent
It when trying example parameter or parameter set, can directly be obtained from the preset parameter collection list, without traversing each XML file
In content, so as to improve the acquisition efficiency of test case parameter.
It is apparent to those skilled in the art that the specific work of the system of foregoing description, device and unit
Make process, can refer to corresponding processes in the foregoing method embodiment, for brevity, does not repeat separately herein.
In addition, each functional unit in each embodiment of the present invention can be physically independent, can also two or
More than two functional units integrate, and can be all integrated in a processing unit with all functional units.It is above-mentioned integrated
Functional unit both can take the form of hardware realization, can also be realized in the form of software or firmware.
Those of ordinary skill in the art will appreciate that: if the integrated functional unit is realized and is made in the form of software
It is independent product when selling or using, can store in a computer readable storage medium.Based on this understanding,
Technical solution of the present invention is substantially or all or part of the technical solution can be embodied in the form of software products,
The computer software product is stored in a storage medium comprising some instructions, with so that calculating equipment (such as
Personal computer, server or network equipment etc.) various embodiments of the present invention the method is executed when running described instruction
All or part of the steps.And storage medium above-mentioned includes: USB flash disk, mobile hard disk, read-only memory (ROM), random access memory
Device (RAM), the various media that can store program code such as magnetic or disk.
Alternatively, realizing that all or part of the steps of preceding method embodiment can be (all by the relevant hardware of program instruction
Such as personal computer, the calculating equipment of server or network equipment etc.) it completes, described program instruction can store in one
In computer-readable storage medium, when described program instruction is executed by the processor of calculating equipment, the calculating equipment is held
The all or part of the steps of row various embodiments of the present invention the method.
Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention., rather than its limitations;To the greatest extent
Present invention has been described in detail with reference to the aforementioned embodiments for pipe, those skilled in the art should understand that: at this
Within the spirit and principle of invention, it is still possible to modify the technical solutions described in the foregoing embodiments or right
Some or all of the technical features are equivalently replaced;And these are modified or replaceed, and do not make corresponding technical solution de-
From protection scope of the present invention.