Embodiment
For the purpose, technical scheme and advantage of the embodiment of the present application are more clearly understood, with reference to embodiment and attached
Figure, is described in further details to the embodiment of the present application.Here, the illustrative examples of the embodiment of the present application and its saying
It is bright to be used to explain the embodiment of the present application, but it is not intended as the restriction to the embodiment of the present application.
Below in conjunction with the accompanying drawings, the embodiment to the embodiment of the present application is described in further detail.
With reference to shown in Fig. 1, the system interface method of testing of the embodiment of the present application comprises the following steps:
S101, obtains the service request that mock objects are initiated.
Wherein, mock objects are pre-configured, and its configuration can be for example as follows:
Add Mock With Cond(String mockId,Object expect,String cond,String iocConfig)
The class that mockId-mark is intercepted, i.e. object invocation object
The desired returning an object value of expect-structure
Cond-according to the processing of condition progress returning an object value
S102, after the returning an object value that object invocation object is returned for the service request is got, according to default
Returning an object value described in logic Modification is handled, expected returning an object value is obtained.
In the embodiment of the application, when the processing logic has a variety of, these processing logics can be unified by one
Processing module is returned to complete.
In another embodiment of the application, as shown in figure 3, when the processing logic has a variety of, every kind of processing is patrolled
Volume can by return correspondingly processing module complete (upon power-up of the system, these return processing modules can be initialised
And be loaded into internal memory), and the mock objects initiate service request in advance with one return processing module tie up
It is fixed.For example following configuration can be increased when mock is configured:
The identification name of iocConfig-return processing module
The identification name is to indicate the return processing module that this invocation target calls the binding required for object, generally
The identification name of the return processing module can be carried in the service request that mock objects are sent, when there is the object invocation pair
When the service request of elephant is intercepted, corresponding return processing module will be called according to the identification name for returning to processing module
(after returning an object value that i.e. object invocation object is returned for service request is intercepted, can be according to being carried in service request
Mark selection returns to processing module).General, binding is only called effectively to this, can basis when calling next time
Need to bind any other return processing module in advance, to realize the test under other mock scenes.
Because a processing logic generally corresponds to a test scene, so since, the not only function of each test scene stroke
Point than more visible, parameter level is easily understood, with preferable decoupling property;But also facilitate it is extended with the later stage
His test scene, without changing original return processing module, only need to increase new return processing module can
With.
In the embodiment of the application, the returning an object value according to default processing logic Modification can include:
Specific input parameter in the service request changes the specific output parameter in the returning an object value.
For example, the ID (identification) that certain object invocation object is generated after performing every time is random, and
Object invocation object is usually that some in test case needs the part tested, but in whole test case, due to
It is relevant between usual context, is at this moment accomplished by running through whole test case with same ID, therefore,
Call and be accomplished by changing object invocation object return according to predefined conditional attribute after the object invocation object
ID in returning an object value.
Such as cond=" return_param1=request_param1, return_param2=request_param1 " are represented
The parameter value for entering parameter entitled " request_param1 " in ginseng request is set to the parameter in returning an object value:
Return_param1 ...
Certainly, as the case may be with need the return_param1 can also to take moduli formula for complex object, so as to
Any parameter is got to realize from any complicated blob.Such as:
Parameter is taken from subobject:Param.id, param.name ...
Parameter is taken from array:param[1].id
Parameter is taken from list:
Fundamental objects:param_list[1]
Complex object:param_list[1].id
Parameter is taken from map:
Fundamental objects:param_map(key)
Complex object:param_map(key).id
Since so, finally realize and returning an object value is adjusted based on input parameter, so as to obtain desired returning an object value
Purpose.
In another embodiment of the application, the returning an object value according to default processing logic Modification can also be wrapped
Include:
Specific output parameter in returning an object value is changed according to predefined conditional attribute.After service request is got,
Object invocation object carries out business processing, the returning an object value to be obtained returned to object invocation object according to normal flow
Afterwards, the specific output parameter in the returning an object value is changed according to predefined conditional attribute so that what is finally returned that is the phase
The returning an object value of prestige.Such as cond=" return_param1=xxx, return_param2=yyy ", then it represents that will be normal
The output parameter value of entitled " return_param1 " is revised as xxx in the result object that business is returned;And by regular traffic
The output parameter value of entitled " return_param2 " is revised as yyy in the result object of return.
For example, certain output parameter of return is true after certain object invocation object has been performed, if it is desired to the output
The return of parameter is flase, then needs true replacing with flase, to ensure that follow-up whole test case is down performed
Desirably carry out.
In another embodiment of the application, the returning an object value according to default processing logic Modification can also be wrapped
Include:
When the mock objects need to repeatedly call same object invocation object and be provided with multiple desired returns in advance
During object, determined to select in the multiple desired returning an object value according to the specific instruction parameter carried in service request
Which calls rear desired returning an object value as this.
Such as cond=" PARAM=trans_type, withdraw=1, dback=2 " represent to judge the specific finger in request
Show parameter trans_type, first object is returned when its value is ' withdraw', the is returned when its value is ' dback'
Two objects.
For example, A, B, tri- returning an object values of C, certain test case disposably are set to certain object invocation object
This object invocation object may be called for 3 times, desirably, it is contemplated that first time invocation target is called and returned after object
Returning an object value be C, second of invocation target calls the returning an object value that is returned after object to be A, mesh is called for the third time
Mark calls the returning an object value returned after object to be B, therefore, it can certain specific instruction in pre-defined condition
Parameter determines which returning an object value should be specifically returned every time.
S103, the expected returning an object value is returned to the mock objects.
Although the process flow of each embodiment of the method description above includes the multiple operations occurred with particular order,
It is, it will be apparent that, these processes can include more or less operations, and these operations can be suitable as needed
Sequence is performed or performed parallel (such as using parallel processor or multi-thread environment).
The embodiment of the present application can be after the returning an object value that object invocation object is returned for service request be got, according to pre-
If processing logic Modification returning an object value, expected returning an object value is obtained, it is achieved thereby that can be flexibly according to reality
Result or reality required parameter to change returning an object value, meet constructed in system interface test automation it is various
The requirement of complicated business scenario.Also, the embodiment of the present application can also be handled by different return processing modules
Different logical process scenes, therefore, when subsequently if desired for test scene extension is carried out, addition is new to return to processing module
, it is very convenient without being modified to original return processing module.
Corresponding with above method embodiment with reference to shown in Fig. 2, the system interface test device of the application includes:
Acquisition request module 21, for obtaining the service request that simulation mock objects are initiated.Wherein, mock objects
Pre-set, for example:
Add Mock With Cond(String mockId,Object expect,String cond,String iocConfig)
The class that mockId-mark is intercepted, i.e. object invocation object
The desired returning an object value of expect-structure
Cond-according to the processing of condition progress returning an object value
Processing module 22 is returned to, for getting the return pair that object invocation object is returned for the service request
As rear, the returning an object value according to default processing logic Modification, expected returning an object value is obtained.
In the embodiment of the application, when the processing logic has a variety of, these processing logics can be unified by one
Processing module is returned to complete.
In another embodiment of the application, when the processing logic has a variety of, every kind of processing logic can be by one a pair
The return processing module answered completes that (upon power-up of the system, these return to processing modules and can be initialised and be loaded into internal memory
In), and the service request that the mock objects are initiated returns to processing module binding with one in advance.For example in mock
Following configuration can be increased during configuration:
The identification name of iocConfig-return processing module
The identification name is to indicate the return processing module that this invocation target calls the binding required for object, generally
The identification name of the return processing module can be carried in the service request that mock objects are sent, when there is the object invocation pair
When the service request of elephant is intercepted, corresponding return processing module will be called according to the identification name for returning to processing module
(after returning an object value that i.e. object invocation object is returned for service request is intercepted, can be according to being carried in service request
Mark selection returns to processing module).General, binding is only called effectively to this, can basis when calling next time
Need to bind any other return processing module in advance, to realize the test under other mock scenes.
Because a processing logic generally corresponds to a test scene, so since, the not only function of each test scene stroke
Point than more visible, parameter level is easily understood, with preferable decoupling property;But also facilitate it is extended with the later stage
His test scene, without changing original return processing module, only need to increase new return processing module can
With.
In the embodiment of the application, the returning an object value according to default processing logic Modification can include:
Specific input parameter in the service request changes the specific output parameter in the returning an object value.Citing
For, the ID (identification) that generates is random, and object invocation after certain object invocation object is performed every time
Object is usually that some in test case needs the part tested, but in whole test case, above and below generally
It is relevant between text, is at this moment accomplished by running through whole test case with same ID, therefore, has called
It is accomplished by changing the return pair of object invocation object return after the object invocation object according to predefined conditional attribute
ID as in.
Such as cond=" return_param1=request_param1, return_param2=request_param1 " are represented
The parameter value for entering parameter entitled " request_param1 " in ginseng request is set to the parameter in returning an object value:
Return_param1 ...
Certainly, as the case may be with need the return_param1 can also to take moduli formula for complex object, so as to
Any parameter is got to realize from any complicated blob.Such as:
Parameter is taken from subobject:Param.id, param.name ...
Parameter is taken from array:param[1].id
Parameter is taken from list:
Fundamental objects:param_list[1]
Complex object:param_list[1].id
Parameter is taken from map:
Fundamental objects:param_map(key)
Complex object:param_map(key).id
Since so, finally realize and returning an object value is adjusted based on input parameter, so as to obtain desired returning an object value
Purpose.
In another embodiment of the application, the returning an object value according to default processing logic Modification can also be wrapped
Include:
Specific output parameter in returning an object value is changed according to predefined conditional attribute.After service request is got,
Object invocation object carries out business processing, the returning an object value to be obtained returned to object invocation object according to normal flow
Afterwards, the specific output parameter in the returning an object value is changed according to predefined conditional attribute so that what is finally returned that is the phase
The returning an object value of prestige.Such as cond=" return_param1=xxx, return_param2=yyy ", then it represents that will be normal
The output parameter value of entitled " return_param1 " is revised as xxx in the result object that business is returned;And by regular traffic
The output parameter value of entitled " return_param2 " is revised as yyy in the result object of return.
For example, certain output parameter of return is true after certain object invocation object has been performed, if it is desired to the output
The return of parameter is flase, then needs true replacing with flase, to ensure that follow-up whole test case is down performed
Desirably carry out.
In another embodiment of the application, the returning an object value according to default processing logic Modification can also be wrapped
Include:
When the mock objects need to repeatedly call same object invocation object and be provided with multiple desired returns in advance
During object, determined to select in the multiple desired returning an object value according to the specific instruction parameter carried in service request
Which calls rear desired returning an object value as this.
Such as cond=" PARAM=trans_type, withdraw=1, dback=2 " represent to judge the specific finger in request
Show parameter trans_type, first object is returned when its value is ' withdraw', the is returned when its value is ' dback'
Two objects.
For example, A, B, tri- returning an object values of C, certain test case disposably are set to certain object invocation object
This object invocation object may be called for 3 times, desirably, it is contemplated that first time invocation target is called and returned after object
Returning an object value be C, second of invocation target calls the returning an object value that is returned after object to be A, mesh is called for the third time
Mark calls the returning an object value returned after object to be B, therefore, it can certain specific instruction in pre-defined condition
Parameter determines which returning an object value should be specifically returned every time.
Sending module 23 is returned to, for returning to the expected returning an object value to the mock objects.
The embodiment of the present application can be after the returning an object value that object invocation object is returned for service request be got, according to pre-
If processing logic Modification returning an object value, expected returning an object value is obtained, it is achieved thereby that can be flexibly according to reality
Result or reality required parameter to change returning an object value, meet constructed in system interface test automation it is various
The requirement of complicated business scenario.Also, the embodiment of the present application can also be handled by different return processing modules
Different logical process scenes, therefore, when subsequently if desired for test scene extension is carried out, need to only add new return processing
Module, it is very convenient without being modified to original return processing module.
System, device, module or unit that above-described embodiment is illustrated, can specifically be realized by computer chip or entity,
Or realized by the product with certain function.
For convenience of description, it is divided into various units during description apparatus above with function to describe respectively.Certainly, implementing
The function of each unit can be realized in same or multiple softwares and/or hardware during the application.
Each embodiment in this specification is described by the way of progressive, identical similar portion between each embodiment
Divide mutually referring to what each embodiment was stressed is the difference with other embodiment.Especially for
For system embodiment, because it is substantially similar to embodiment of the method, so description is fairly simple, related part is joined
See the part explanation of embodiment of the method.
In the 1990s, can clearly to distinguish be improvement (example on hardware for the improvement of a technology
Such as, to the improvement of the circuit structures such as diode, transistor, switch) or software on improvement (for method flow
Improvement).However, with the development of technology, the improvement of current many method flows can be considered as hardware electricity
Line structure is directly improved.Designer is nearly all obtained by the way that improved method flow is programmed into hardware circuit
Corresponding hardware circuit.Therefore, it cannot be said that the improvement of a method flow cannot be with hardware entities module come real
It is existing.For example, PLD (Programmable Logic Device, PLD) (such as field programmable gate
Array (Field Programmable Gate Array, FPGA)) it is exactly such a integrated circuit, its logic function
By user is determined to device programming.By designer is voluntarily programmed a digital display circuit " integrated " a piece of
On PLD, without asking chip maker to design and make special IC chip 2.Moreover, such as
The present, substitution manually makes IC chip, and " logic compiler (logic is also used in this programming instead mostly
Compiler) " software realizes that software compiler used is similar when it writes with program development, and to compile it
Also handy specific programming language is write for preceding source code, and this is referred to as hardware description language (Hardware
Description Language, HDL), and HDL is also not only a kind of, but have many kinds, such as ABEL
(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description
Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、
JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL
(Ruby Hardware Description Language) etc., most generally uses VHDL at present
(Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog2.
Those skilled in the art also will be apparent to the skilled artisan that only need to by method flow with above-mentioned several hardware description languages slightly logic compile
Journey is simultaneously programmed into integrated circuit, it is possible to be readily available the hardware circuit for realizing the logical method flow.
Controller can be implemented in any suitable manner, for example, controller can take such as microprocessor or processing
Device and storage can by the computer readable program code (such as software or firmware) of (micro-) computing device meter
Calculation machine computer-readable recording medium, gate, switch, application specific integrated circuit (Application Specific Integrated Circuit,
ASIC), the form of programmable logic controller (PLC) and embedded microcontroller, the example of controller includes but is not limited to following
Microcontroller:ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs
C8051F320, Memory Controller is also implemented as a part for the control logic of memory.
It is also known in the art that in addition to realizing controller in pure computer readable program code mode, it is complete
Entirely can by by method and step carry out programming in logic come cause controller with gate, switch, application specific integrated circuit,
Programmable logic controller (PLC) realizes identical function with the form of embedded microcontroller etc..Therefore this controller can be by
It is considered a kind of hardware component, and hardware component can also be considered as to the device for realizing various functions included in it
Interior structure.Or even, can by for realize the device of various functions be considered as both can be implementation method software
Module can be the structure in hardware component again.
As seen through the above description of the embodiments, those skilled in the art can be understood that the application can
Realized by the mode of software plus required general hardware platform.Understood based on such, the technical scheme of the application
The part substantially contributed in other words to prior art can be embodied in the form of software product, the computer
Software product can be stored in storage medium, and such as ROM/RAM, magnetic disc, CD, including some instructions are used to
So that computer equipment (can be personal computer, server, or network equipment an etc.) execution the application is each
Method described in some parts of individual embodiment or embodiment.
The application can be used in numerous general or special purpose computing system environments or configuration.For example:Personal computer,
Server computer, handheld device or portable set, laptop device, multicomputer system, based on microprocessor
System, set top box, programmable consumer-elcetronics devices, network PC, minicom, mainframe computer, bag
Include DCE of any of the above system or equipment etc..
The application can be described in the general context of computer executable instructions, such as program
Module.Usually, program module include performing particular task or realize the routine of particular abstract data type, program,
Object, component, data structure etc..The application can also be put into practice in a distributed computing environment, it is distributed at these
In computing environment, task is performed by the remote processing devices connected by communication network.In Distributed Calculation ring
In border, program module can be located at including in the local and remote computer-readable storage medium including storage device.
Although depicting the application by embodiment, it will be appreciated by the skilled addressee that the application have it is many deformation and
Change is without departing from spirit herein, it is desirable to which appended claim includes these deformations and changed without departing from this Shen
Spirit please.