The extended method of script
[technical field]
The present invention relates to the extended method for automatized script language.
[background technology]
In automated testing method, the Programming with Pascal Language of normal use automatized script realizes testing measurand, because measurand is varied, often needs to expand the order of automatized script language.The automatized script language of current main flow both provides expansion interface and the API of C language, can use the expansion of C language programming realization order.As publication date be on April 1st, 2009, number of patent application be 200710161587.4 patent documentation achieve automatized script language: the extended method of the order of TCL language, thus the function of expansion TCL script.
The method that the existing API by script carries out explosion command is all bound with script itself, identical function, and different scripts needs to write different explosion commands to realize according to respective method, brings the efficiency of overlapping development.And explosion command, as a part for script analysis program, when expanded function goes wrong, can cause the instability that script resolver runs, thus affect the execution of automatized script.
[summary of the invention]
The technical matters that the present invention need solve overcomes above-mentioned deficiency, provides the extended method of the nonexpondable script of a kind of primary development.
For solving above-mentioned technical matters, the present invention devises a kind of extended method of script, and it comprises the following steps:
Step1: for meeting the demand of automatic test, expand the order of automatized script, specifies the title of an explosion command;
Step2: use scripting language one to support the client of XML-RPC agreement, use the title of explosion command and the form of defined parameters in the client.
Step3: write a server end, at server end definition XML-RPC server end interface and add the expansion module corresponding with explosion command, XML-RPC server end interface comprises the analysis mode of the IP address of the computer at server end place, socket port and command parameter.
Step4: when Run Script program, when running to this explosion command, by client by the title of explosion command and parameter, server end is sent to by XML-RPC agreement according to the form defined, XML-RPC server end interface is to resolving explosion command and parameter afterwards, according to the analysis mode of the good command parameter of predefine, call corresponding expansion module to perform, expansion module calculates, after being finished, result of calculation is returned to client by XML-RPC agreement, result is returned to explosion command by client again, after explosion command returns, this explosion command performs end.
Compared with prior art, in the present invention, the expansion module performing the explosion command of script independently realizes, and binds different from existing with script; After server end realizes expansion module, XML-RPC interface interchange can be passed through in various script, reach the nonexpondable function of primary development.Expansion module concentrates on server end and realizes separately, and the separate operation of script analysis program, and expansion module goes wrong, and does not affect the operation of other partial functions of script.
And, the server end using the present invention to carry out expanding and script perform can be positioned on different computers and run, realize Distributed Calculation, expansion that is more consuming time in script or consumption of natural resource can be calculated in the enterprising row operation of the better server of other performances, make full use of the feature of Distributed Calculation, improve the performance of robotization platform, meet the requirement of complex environment.
[accompanying drawing explanation]
Fig. 1 is the embodiment figure of the extended method of script of the present invention.
[embodiment]
Below in conjunction with drawings and embodiments, the invention will be further described.
The invention provides a kind of extended method of script, can multiple automatized script be supported.When the function that the order of automatized script language provides can not meet the needs of automatic test, need to expand the order of script.The inventive method uses scripting language's client, a server end is write with other programming languages, server end adds corresponding expansion module realize the function needing expansion, client and server end by XML-RPC(XML Remote Procedure Call, i.e. XML remote method invocation (RMI)) agreement carries out communication.When performing this explosion command in automatized script language, order and parameter is sent to server end by client, server end is resolved, after the calculating of expansion module, result of calculation is returned to client, after client receives, result is returned to this order, order performs end and returns results.
The extended method of script of the present invention, concrete step is as follows:
Step1: for meeting the demand of automatic test, expand the order of automatized script, specifies the title of an explosion command;
Step2: use scripting language one to support the client of XML-RPC agreement, use the title of explosion command and the form of defined parameters in the client.
Step3: write a server end, at server end definition XML-RPC server end interface and add the expansion module corresponding with explosion command, XML-RPC server end interface comprises the analysis mode of the IP address of the computer at server end place, socket port and command parameter.
Step4: as shown in Figure 1, when Run Script program, when running to this explosion command, by client by the title of explosion command and parameter, server end is sent to by XML-RPC agreement according to the form defined, XML-RPC server end interface is to resolving explosion command and parameter afterwards, according to the analysis mode of the good command parameter of predefine, call corresponding expansion module to perform, expansion module calculates, after being finished, result of calculation is returned to client by XML-RPC agreement, result is returned to explosion command by client again, after explosion command returns, this explosion command performs end, .
The present invention adopts XML-RPC agreement as the agreement of communication between robotization language scripts and expansion module, the explosion command of script is realized in expansion module, the result of calculation that expansion module generates returns to script by XML-RPC communications protocol, achieve the expansion of script order and distributed execution, the method extends the function of script, can adapt to the automatized script exploitation of main flow.
The invention has the advantages that:
1, versatility: the expansion module of the script that this method is carried out can dock with multiple script, realizes the feature across script, supports multiple script.
2, manageability: on backstage based on unified management, efficiency and the robustness of program operation can be improved for expansion module.
3, extensibility is strong, and the expansion of functional module only need perform at server end, and current most programming language all supports XML-RPC agreement, and the characteristic that can make full use of the language grasped designs.
Above-described is only embodiments of the present invention, it should be pointed out that for the person of ordinary skill of the art at this, without departing from the concept of the premise of the invention, can also make improvement, but these all belongs to protection scope of the present invention.