Summary of the invention
The purpose of this invention is to provide a kind of universal message test approach of judging based on equipment state, may further comprise the steps:
Step 1, be provided with the message that will send;
Step 2 is according to message setting and preservation analog machine attribute;
Step 3 was handled the equipment state after the message according to the setting of analog machine attribute and preservation;
Step 4 judges according to the preset condition of analog machine whether the messaging flow process is correct, is, then returns step 3 and continues to carry out, and not, then shows execution error.
Said step 2 specifically comprises:
Step 20, the number of definition analog machine;
Step 21 is provided with the total attribute of the message that analog machine sends;
Step 22 is loaded into the total attribute information of the message of the number of analog machine and transmission thereof in the internal memory, and binds one group of messaging list according to the total property calculation of message for each analog machine.
Said step 22 specifically may further comprise the steps:
Step 210 is applied for an analog machine;
Step 211 is according to the attribute of configuration file foundation and preservation analog machine;
Step 212 is according to preset step size computation and preserve the analog machine property value;
Step 213 judges to be last analog machine, is not, then returns step 210, otherwise, execution in step 214;
Step 214 finishes.
Total attribute in the said step 21 is the field of message or the character string of judging as state.
Said step 3 specifically comprises:
Step 30 is provided with and preserves analog machine and sends message state afterwards;
Step 31, testing apparatus receives the response message that system under test (SUT) returns, and judges whether the analog machine state is to send a piece of news state afterwards of going up; Be, then send down a piece of news and the state that sends the back analog machine is set, continue execution in step 4;, then do not show and carry out failure.
The transmission of said message and reception are represented with the form of function.
Also comprise before the said step 30:
Step 30 ', the message that treatment of simulated equipment initiatively sends;
Step 30 ", according to the message after handling the attribute or the global variable of analog machine carried out initialization;
Also comprise after the said step 31:
Step 32, the exception procedure of the response message of system under test (SUT) is not received in processing.
The present invention also provides a kind of universal information testing apparatus of judging based on equipment state, comprising:
Message is provided with module, be used to be provided with the message that will send;
Device attribute is provided with module, be used for according to message be provided with the module setting message structure total attribute with calculate the property value that step-length is provided with analog machine;
Message processing module is used for handling the analog machine state after the message according to the setting of analog machine attribute and preservation;
The flow process judge module is used for the correctness according to the state judgement analog machine messaging flow process of analog machine.
Said message processing module comprises message processing unit, is used for according to the setting of analog machine attribute and the state after preserving the analog machine messaging.
Said message processing module also comprises:
Send message processing unit, be used for the message that treatment of simulated equipment initiatively sends;
Initialization unit is used for according to the message after handling analog machine attribute or global variable being carried out initialization;
The timeout treatment unit is used to handle the exception procedure of the response message of not receiving system under test (SUT).
Compared with prior art, the present invention has following beneficial effect:
(1) the present invention is through the attribute of configuration analog machine; Make different identity (Identification; ID) analog machine only needs the ID that revises analog machine just can reuse test case in carrying out identical flow testing process, need not remodify the attribute of message;
(2) flow process is identical for same equipment; But the variation on the data structure in the edition upgrading process, may occur, such as the increase or the deletion of certain field, this situation only need static analysis be just passable once again to the header file of data structure; Field newly-increased or deletion mends 0 automatically; Message structure does not need again design cycle and use-case after having become like this, therefore, the system with different messages structure is had versatility;
(3) a plurality of analog machines only need be write a processing scripts when receiving and send identical message, have avoided writing the duplication of labour of a large amount of identical scripts, have improved the efficient of system testing;
(4) there is not the restriction of analog machine number, only needs to revise a configuration file and just can accomplish simulation the physical device of respective numbers.
(5) test is carried out automatically, because the user possibly design thousands of test case up to a hundred, when carrying out, the user at first chooses the test case that needs execution, selects " execution " just can carry out down successively according to the order of selecting then.In the implementation, judge the success or the failure of every use-case according to the state that designs in each use-case.The user can set " execution " afterwards, and waiting is finished checks the result of the success or the failure of all use-cases, and in pilot process, does not need to operate again.
Embodiment
The present invention carries out a plurality of information receiving and transmittings tests and flow testing through to the judgement of analog machine state, and wherein, analog machine is to be used for simulating in the actual test process, is used to send or receive the equipment of message, like mobile phone etc.In the flow testing process; Testing apparatus of the present invention utilizes the ID of analog machine to distinguish the identical message of sending or receiving; And judge the message that next step needs send according to the state that the ID of analog machine takes out analog machine, to realize control to the execution of the identical flow process of different analog machines.
Be elaborated below in conjunction with the accompanying drawing specific embodiments of the invention.
As shown in Figure 1, Fig. 1 is a method of testing flow chart of the present invention, comprises among the figure:
Step 1, be provided with the message that will send;
Step 2 is according to message setting and preservation analog machine attribute;
Wherein the attribute of analog machine is the total attribute and the exclusive attribute of analog machine.For example, for one group of mobile phone, its total attribute is custom IC (International Mobile SubscriberIdentification Number; IMSI), Electronic Serial Number (Electronic Serial Number; ESN) etc., the total property value and the step-length of mobile phone is provided with, if the number property value of first mobile phone is made as 13770233556; Step-length is made as 2, and the number of second mobile phone is exactly 13770233558 so.
Its exclusive attribute can be set to a plurality of string attributes, and its property value is preserved with a tabulation, and the tester can add, be provided with, revise these property values through script.
Step 3 was handled the equipment state after the message according to the setting of analog machine attribute and preservation;
Select an analog machine and the message that need send to system under test (SUT); After the message of choosing sends; This message can be replaced the field value in the message automatically according to the attribute of analog machine, promptly according to the field value in the message state that this analog machine presets is set.
Step 4 judges according to the preset condition of analog machine whether the messaging flow process is correct.
When testing apparatus is received the response message that system under test (SUT) returns, judge at first whether analog machine is in the state that presets, if, then make corresponding response, and reset state value according to this preset condition, otherwise, show and carry out failure.The flow process control of having formed an equipment is judged in the transmitting-receiving of a plurality of message.
When carrying out script, testing apparatus can judge message from which analog machine is sent and by which analog machine received according to the ID of analog machine, thereby judges the correctness of flow performing.If message is not to send or do not received by predetermined analog machine from predetermined analog machine; Will demonstrate the information of execution error so; If message is to send or received by predetermined analog machine from predetermined analog machine; Prove that so this flow process is correct, then return step 3, continue to carry out.
When sending message, need the user to send, when receiving message, also can calculate ID number that receives message according to some field according to the ID of selected equipment, but cumbersome.So when receiving message, organized a message structure in addition, this structure comprises device id and the message data that really sends.Testing apparatus is receiving ID number that just can directly take out transmitting apparatus when message is handled.
Different analog machines is when walking the same stream journey, as long as it is just passable to revise the ID of analog machine.
Step as shown in Figure 2, that Fig. 2 specifically comprises for step 2 comprises among Fig. 2:
Step 20, the number of definition analog machine;
The number of analog machine is that the configuration file through testing apparatus of the present invention reads.
Step 21 is provided with the total attribute of the message that analog machine sends;
The field nodename that should total attribute comprises message, for example: Field.Field.Field, and the change step etc. of message field between neighbouring device, step-length is that the numerical value of zero words message field is constant.
Step 22 is loaded into the total attribute information of the message of the number of analog machine and transmission thereof in the internal memory, and binds one group of information list according to the total property calculation of message for each analog machine.
The Property Name and the property value that comprise analog machine in the tabulation.
The total attribute that is provided with in the step 21 can be represented with a tabulation.As shown in Figure 3, Fig. 3 is the flow chart that the total attribute list of analog machine is set, and comprises the steps: among Fig. 3
Step 210 is applied for an analog machine;
Step 211 is according to the attribute of configuration file foundation and preservation analog machine;
The attribute of each analog machine is kept in the tabulation, and each the bar record in the tabulation comprises: Property Name, property value and attribute type, attribute type are masked as message data or character string.
Step 212 is according to preset step size computation and preserve the analog machine property value;
These property values, are saved in the attribute list of equipment in the process of internal memory in device loads, with apparatus bound.
Step 213 judges to be last analog machine, is not, then returns step 210, and the property value of next analog machine is set; Otherwise, execution in step 214;
Wherein, attribute can be that the field of message also can be the character string of judging as state.
Step 214 finishes.
Step as shown in Figure 4, that Fig. 4 specifically comprises for step 3 comprises among Fig. 4:
Step 30 is provided with and preserves analog machine and sends message state afterwards;
When sending message, analog machine can be replaced the property value of binding field automatically according to side-play amount.
Step 31, testing apparatus receives the response message that system under test (SUT) returns, and judges whether the analog machine state is to send a piece of news state afterwards of going up; Be, then send down a piece of news and the state that sends the back analog machine is set, continue execution in step 4;, then do not show and carry out failure.
Wherein, the reception of message and send the form that is written as function with script, proc sengmsg1{id} for example, therefore, different analog machines sends identical message can call identical function, only revises one and is lowered to ginseng, can avoid the repetition of script.
As required, further comprising the steps of before the step 30:
Step 30 ', the message that treatment of simulated equipment initiatively sends;
The message that analog machine initiatively sends is for example started shooting, shutdown etc., the situation that testing apparatus can be current according to analog machine, and whether decision continues next step test.
Step 30 ", according to the message after handling the attribute or the global variable of analog machine carried out initialization.
Further comprising the steps of after the step 31:
Step 32, the exception procedure of the response message of system under test (SUT) is not received in processing.
If testing apparatus is not received the response message that system under test (SUT) returns, then show the information of execution error, carry out again or the next flow process of continuation execution.
The complete flow process of message test approach of the present invention is described with a concrete example below.
The data of three structures below in a test macro, having:
typedef?struct
{
int m;
char?n;
}St1;
typedef?struct
{
int a;
St1 b;
}St2;
typedef?struct
{
char?a;
St1 b;
}St3;
Suppose an analog machine the message structure that will send be St2, St3, initial value is 1, step-length is 2, it is b.m that user property is set.First equipment is sending St2 like this, and the b.m field value is that 1, the second equipment is sending St2 during the message of St3 structure, and the b.m field value all is 3 during the message of St3 structure.In the process of test; When sending the message of these two kinds of structures; Testing apparatus can be automatically according to the initial value of message and step-length calculate this analog machine the message word segment value that will send; And this message word segment value is kept in the attribute list of analog machine so that the total attribute of analog machine is carried out unified management, and with these property values as sending or receive the foundation that message flow is judged.
In script, can dynamically add the attribute of analog machine, the attribute that dynamically adds is the exclusive attribute of analog machine, for example state setting: SETPROP$ device id " state " " sendmsg1 ".
Testing apparatus takes out its state according to the ID of analog machine after receiving the response message that system under test (SUT) returns, and according to the analog machine state judge next bar the message that will send.
State reads: set ms_state [GETPROP$ device id " state "].
For example: analog machine 1 is walked different flow processs simultaneously with analog machine 2, but can receive the identical response message that system under test (SUT) returns.Analog machine 1 has sent after a piece of news sendmsg1; Its state is set to sendmsg1; Analog machine 2 has sent after a piece of news sendmsg2, and its state is set to sendmsg2, and they will can receive the receivemsg message that system under test (SUT) returns afterwards.The following a piece of news that analog machine 1 sends is sendmsg3, and the following a piece of news that analog machine 2 sends is sendmsg4.
When analog machine is received the receivemsg message that system under test (SUT) returns; Testing apparatus just can judge whether the message of transmitting-receiving is correct through the set ms_state [GETPROP$resid1 " state "] that reads of state; Wherein, resid1 is a device number, if ms_state=sendmsg1; Analog machine 1 sends a piece of news sendmsg3 down so, and the state that has sent back testing apparatus analog machine 1 is set to sendmsg3.Otherwise send message sendmsg4 by analog machine 2, and the state after its transmission message sendmsg4 is set to sendmsg4.
Also walk this flow process if test other analog machine, so only need ID number of same script be changed and just can accomplish the test of identical function.
Be the technical problem that realizes that the present invention will solve; The present invention also provides a kind of universal information testing apparatus of judging based on equipment state; As shown in Figure 5; Fig. 5 is a testing apparatus block diagram of the present invention, comprises among Fig. 5: message is provided with module, device attribute is provided with module, message processing module and process control module.
At first, by message be provided with module be provided with the message that will send.
The process that message is set is: message is provided with module the header file of system under test (SUT) is carried out the structural information analysis; Obtain to send the data structure information of message; And extract data structure information and carry out the calculating and the encoding and decoding of side-play amount, the message that will send to obtain.
Device attribute is provided with module is provided with the message structure of module setting according to message total attribute and calculating step-length, the analog machine attribute is set, and these attributes are carried out list management.
Message processing module comprises message processing unit, is used for according to the setting of analog machine attribute and preserves the state after analog machine was handled message.
Message processing unit be utilize Tool Command Language (Tool Command Language, TCL) script is realized, ID, state and type of message through analog machine in design are as the foundation of judging, to reach the unified management to messaging.
Message processing unit receives after the response message that system under test (SUT) returns, and according to the analog machine ID that system under test (SUT) sends, the state information of taking out analog machine is judged the information that next bar needs sends according to state information.This a part of processing also is the form according to analog machine ID+ state, can reuse, the redundancy of effort of having avoided the identical requirements of process of distinct device test to write identical script.
In order further to strengthen its function, message processing module also comprises:
Send message processing unit, be used for the message that treatment of simulated equipment initiatively sends;
These message decide the operation of carrying out relevant with the concrete message name of sending of the ID of analog machine; For example start shooting, shutdown etc.; This part adopts the form of analog machine ID+ operational order when handling; To realize versatility, only need change that the ID of analog machine just can accomplish the test of the identical flow process of different analog machines, and not receive the restriction of analog machine number.
Initialization unit is carried out initialization according to the message after handling to analog machine attribute or global variable;
For example, the analog machine that has is in idle condition, and the analog machine that has is in busy state, utilizes initialization unit to carry out initialization to the operating state of analog machine.
The timeout treatment unit is used for handling the exception procedure of the response message of not receiving system under test (SUT).
If the response message of system under test (SUT) is not received in the timeout treatment unit, then show the information of execution error, carry out again or the next flow process of continuation execution.
The flow process judge module; Judge the correctness of analog machine messaging flow process according to analog machine ID; That is, receive the message that testing apparatus returns after, judge according to the ID of the analog machine that from message, takes out this message is from which equipment to send; And should receiving, thereby the correctness of judgement flow performing by which equipment.
The above only is a preferred implementation of the present invention; Should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the principle of the invention; Can also make some improvement and retouching, these improvement and retouching also should be regarded as protection scope of the present invention.