Invention content
An embodiment of the present invention provides a kind of method and devices for realizing script argument, can improve realization script argument
The speed of change.
On the one hand, an embodiment of the present invention provides a kind of methods for realizing script argument, including:
Encoded original character string is determined from encoded script to be parameterized, wherein in the original character string
Including parameterized object;
Obtain the corresponding at least one target object of the parameterized object;
The encoded original character string is decoded, the original character string is generated;
Each parameterized object is identified from the original character string;
For each parameterized object, execute:
From encoded original character string, the corresponding encoded target string of parameter current object is identified;
According to the parameter current object, the corresponding encoded substitute character string of each target object is generated;
Encoded target string in script to be parameterized described in will be encoded replaces with alternative parameter, wherein
The alternative parameter can be at least one encoded substitute character string of value any one.
Further,
It is described from encoded original character string, identify the corresponding encoded target character of parameter current object
String, including:
In the original character string, determine the first character of the original character string to the parameter current object
Previous character the first number of characters;
The first remainder behind first number of characters divided by 3 is determined, using first remainder as the digit taken forward;
It regard the sum of number of characters of the digit taken forward and the parameter current object as the second number of characters;
Determine the second remainder behind second number of characters divided by 3;
According to second remainder, the digit taken backward is determined, wherein described to take backward when second remainder is 0
Digit be 0, when second remainder be 1 when, the digit taken backward be 2, when second remainder be 2 when, it is described to
The digit taken afterwards is 1;
According to formula one, determine that the first character of the target string is m-th of encoded original character string
Character, wherein the formula one is:
Wherein, d is first number of characters, and q is the digit taken forward;
According to formula two, determine that the length of the target string is n, wherein the formula two is:
Wherein, c is the number of characters of the parameter current object, and h is described to be taken backward
Digit;
According to the m and the n, determine that the parameter current object is corresponding from encoded original character string
The target string of coding.
Further,
It is described according to the parameter current object, generate the corresponding encoded substitute character of each target object
String, including:
It is adjacent with the parameter current object before determining the parameter current object in the original character string
Q character constitute the first character string;
In the original character string, determine after the parameter current object with the parameter current object phase
The second character string that h adjacent character is constituted;
For each target object, execute:
By first character string, current target object and second character string, it is combined into third character string, wherein
The third character string is from left to right first character string, the current target object and second character string successively;
The third character string is encoded, the corresponding encoded substitute character of the current target object is generated
String;
Wherein, the number of characters of each target object is identical as the number of characters of the parameterized object.
Further,
This method further comprises:Pre-set script implementation strategy;
Described according to the parameter current object, the corresponding encoded replacement word of each target object is generated
After symbol string, further comprise:
For each parameterized object, the corresponding each encoded substitute character string of parameter current object is write
Enter into the corresponding Parameter File of the parameter current object;
According to each corresponding Parameter File of parameterized object and the script implementation strategy, configuration code is generated;
The configuration code is appended in the script argument configuration file of the script to be parameterized, so that described wait joining
Numberization script can be run according to each corresponding Parameter File of character string to be replaced and the script implementation strategy.
Further,
Script to be parameterized includes described in encoded:Script to be parameterized described in after being encoded by base64;
The encoded original character string includes:The original character string after being encoded by base64;
It is described to be decoded the encoded original character string, the original character string is generated, including:
The encoded original character string is decoded by base64, generates the original character string;
It is described according to the parameter current object, generate the corresponding encoded substitute character of each target object
String, including:
According to the parameter current object, the corresponding volume encoded by base64 of each target object is generated
The substitute character string of code.
On the other hand, an embodiment of the present invention provides a kind of devices for realizing script argument, including:
Originally determined unit, for determining encoded original character string from encoded script to be parameterized, wherein
The original character string includes parameterized object;
Acquiring unit, for obtaining the corresponding at least one target object of the parameterized object;
Original decoded unit generates the original character string for the encoded original character string to be decoded;
Recognition unit, for identifying each parameterized object from the original character string;
Parameterized units, for for each parameterized object, executing:
From encoded original character string, the corresponding encoded target string of parameter current object is identified;
According to the parameter current object, the corresponding encoded substitute character string of each target object is generated;
Encoded target string in script to be parameterized described in will be encoded replaces with alternative parameter, wherein
The alternative parameter can be at least one encoded substitute character string of value any one.
Further,
The parameterized units, it is described from encoded original character string executing, identify parameter current object
When corresponding encoded target string, it is specifically used for:
In the original character string, determine the first character of the original character string to the parameter current object
Previous character the first number of characters;
The first remainder behind first number of characters divided by 3 is determined, using first remainder as the digit taken forward;
It regard the sum of number of characters of the digit taken forward and the parameter current object as the second number of characters;
Determine the second remainder behind second number of characters divided by 3;
According to second remainder, the digit taken backward is determined, wherein described to take backward when second remainder is 0
Digit be 0, when second remainder be 1 when, the digit taken backward be 2, when second remainder be 2 when, it is described to
The digit taken afterwards is 1;
According to formula one, determine that the first character of the target string is m-th of encoded original character string
Character, wherein the formula one is:
Wherein, d is first number of characters, and q is the digit taken forward;
According to formula two, determine that the length of the target string is n, wherein the formula two is:
Wherein, c is the number of characters of the parameter current object, and h is described to be taken backward
Digit;
According to the m and the n, determine that the parameter current object is corresponding from encoded original character string
The target string of coding.
Further,
The parameterized units, it is described according to the parameter current object executing, generate each target object
When corresponding encoded substitute character string, it is specifically used for:
It is adjacent with the parameter current object before determining the parameter current object in the original character string
Q character constitute the first character string;
In the original character string, determine after the parameter current object with the parameter current object phase
The second character string that h adjacent character is constituted;
For each target object, execute:
By first character string, current target object and second character string, it is combined into third character string, wherein
The third character string is from left to right first character string, the current target object and second character string successively;
The third character string is encoded, the corresponding encoded substitute character of the current target object is generated
String;
Wherein, the number of characters of each target object is identical as the number of characters of the parameterized object.
Further,
The device further comprises:Storage unit, for preserving script implementation strategy;
The parameterized units are further used for generating each mesh according to the parameter current object described
After marking the corresponding encoded substitute character string of object, execute:
For each parameterized object, the corresponding each encoded substitute character string of parameter current object is write
Enter into the corresponding Parameter File of the parameter current object;
According to each corresponding Parameter File of parameterized object and the script implementation strategy, configuration code is generated;
The configuration code is appended in the script argument configuration file of the script to be parameterized, so that described wait joining
Numberization script can be run according to each corresponding Parameter File of character string to be replaced and the script implementation strategy.
Further,
Script to be parameterized includes described in encoded:Script to be parameterized described in after being encoded by base64;
The encoded original character string includes:The original character string after being encoded by base64;
The original decoded unit, for decoding the encoded original character string by base64, described in generation
Original character string;
The parameterized units, it is described according to the parameter current object executing, generate each target object
When corresponding encoded substitute character string, it is specifically used for:
According to the parameter current object, the corresponding volume encoded by base64 of each target object is generated
The substitute character string of code.
In embodiments of the present invention, original character string, getting parms pair are decoded from encoded original character string
As corresponding at least one target object, identify that each parameterized object is corresponding from encoded script to be parameterized
The target string of coding has been compiled using each parameterized object of the corresponding alternative parameter replacement of each parameterized object is corresponding
The target string of code, realizes that the parametrization of script to be parameterized, whole process are automatically performed, and participates in, carries without artificial
The high speed for realizing script argument.
Specific implementation mode
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention
In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is
A part of the embodiment of the present invention, instead of all the embodiments, based on the embodiments of the present invention, those of ordinary skill in the art
The every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.
As shown in Figure 1, an embodiment of the present invention provides a kind of method for realizing script argument, this method may include with
Lower step:
Step 101:Encoded original character string is determined from encoded script to be parameterized, wherein described original
Character string includes parameterized object;
Step 102:Obtain the corresponding at least one target object of the parameterized object;
Step 103:The encoded original character string is decoded, the original character string is generated;
Step 104:Each parameterized object is identified from the original character string;
Step 105:For each parameterized object, execute:
From encoded original character string, the corresponding encoded target string of parameter current object is identified;
According to the parameter current object, the corresponding encoded substitute character string of each target object is generated;
Encoded target string in script to be parameterized described in will be encoded replaces with alternative parameter, wherein
The alternative parameter can be at least one encoded substitute character string of value any one.
In embodiments of the present invention, original character string, getting parms pair are decoded from encoded original character string
As corresponding at least one target object, identify that each parameterized object is corresponding from encoded script to be parameterized
The target string of coding has been compiled using each parameterized object of the corresponding alternative parameter replacement of each parameterized object is corresponding
The target string of code, realizes that the parametrization of script to be parameterized, whole process are automatically performed, and participates in, carries without artificial
The high speed for realizing script argument.
In embodiments of the present invention, it there may be multiple parameters object in original character string, needs to parameterize these
Object is parameterized.Wherein, parameterized object can be specified with user.For example, parameterized object is " zhangsan ",
In one section of original character string, in different positions there are multiple " zhangsan ", these " zhangsan " are parametrizations pair
As being required for being replaced by corresponding alternative parameter for each " zhangsan ".
In an embodiment of the present invention, described from encoded original character string, identify parameter current object pair
The encoded target string answered, including:
In the original character string, determine the first character of the original character string to the parameter current object
Previous character the first number of characters;
The first remainder behind first number of characters divided by 3 is determined, using first remainder as the digit taken forward;
It regard the sum of number of characters of the digit taken forward and the parameter current object as the second number of characters;
Determine the second remainder behind second number of characters divided by 3;
According to second remainder, the digit taken backward is determined, wherein described to take backward when second remainder is 0
Digit be 0, when second remainder be 1 when, the digit taken backward be 2, when second remainder be 2 when, it is described to
The digit taken afterwards is 1;
According to formula one, determine that the first character of the target string is m-th of encoded original character string
Character, wherein the formula one is:
Wherein, d is first number of characters, and q is the digit taken forward;
According to formula two, determine that the length of the target string is n, wherein the formula two is:
Wherein, c is the number of characters of the parameter current object, and h is described to be taken backward
Digit;
According to the m and the n, determine that the parameter current object is corresponding from encoded original character string
The target string of coding.
For example, one section of original character string is:[usercode:zhangsan,password:123456,
username:Zhang San].Parameterized object is [zhangsan].[zhangsan] previous character be [:], the first number of characters is
[usercode:] length, that is, 9, the first remainder is 0, then, the digit taken forward is 0.The word of parameter current object
It is 8 to accord with number, and the second number of characters is 8, and the second remainder is 2, then, the digit taken backward is 1.
In an embodiment of the present invention, described according to the parameter current object, generate each target object pair
The encoded substitute character string answered, including:
It is adjacent with the parameter current object before determining the parameter current object in the original character string
Q character constitute the first character string;
In the original character string, determine after the parameter current object with the parameter current object phase
The second character string that h adjacent character is constituted;
For each target object, execute:
By first character string, current target object and second character string, it is combined into third character string, wherein
The third character string is from left to right first character string, the current target object and second character string successively;
The third character string is encoded, the corresponding encoded substitute character of the current target object is generated
String;
Wherein, the number of characters of each target object is identical as the number of characters of the parameterized object.
In embodiments of the present invention, it is needed with the corresponding third character of parameterized object for the parametrization of parameterized object
String is unit, for identical parameterized object, since position of the parameters object in original character string is different, with
And the character difference that parameters object is adjacent, corresponding third character string may also be different.
Specifically, third character string can be encoded by base64.
Continue with [usercode:zhangsan,password:123456,username:Zhang San] this original character string
For, it since q is 0, determines that [zhangsan] corresponding first character string is sky, since h is 1, determines that [zhangsan] is corresponding
The second character string be [,].One of target object is [chenxing], and [zhangsan] this parameterized object is corresponding
Third character string is [chenxing ,], is encoded to [chenxing ,], and [zhangsan] this parameterized object pair is generated
The encoded substitute character string answered.
In an embodiment of the present invention, this method further comprises:Pre-set script implementation strategy;
Described according to the parameter current object, the corresponding encoded replacement word of each target object is generated
After symbol string, further comprise:
For each parameterized object, the corresponding each encoded substitute character string of parameter current object is write
Enter into the corresponding Parameter File of the parameter current object;
According to each corresponding Parameter File of parameterized object and the script implementation strategy, configuration code is generated;
The configuration code is appended in the script argument configuration file of the script to be parameterized, so that described wait joining
Numberization script can be run according to each corresponding Parameter File of character string to be replaced and the script implementation strategy.
In embodiments of the present invention, the additional configuration code into script argument configuration file so that running parameter
Change when parameterize script, the corresponding alternative parameter of encoded substitute character string replacement in Parameter File can be utilized.
Also, script to be parameterized can be run according to script implementation strategy.
Specifically, script argument configuration file can be [the name prm of script to be parameterized] file.
Specifically, script implementation strategy can specify that in user different in script to be parameterized, different iterations
Parameter this how value.
For example, script implementation strategy may include the following contents:
select next row:Users different sequential/random/unique how value:Sequentially/random/
It is fixed
update value on:The same users of eachiteration/eachoccurrence/once how value:
Each iteration/appearance/fixation every time
when out of values:Abort vuser/ContinueCycle/ContinueWithLast parameter values are not
Strategy when enough:Interrupt Virtual User/cycle/with the last one value
Allocate Vuser Values:Automatically/Allocate Valus be each user distribution how much
Row data:Automatic distribution/distribution fixed quantity
In an embodiment of the present invention, the encoded script to be parameterized includes:Institute after being encoded by base64
State script to be parameterized;
The encoded original character string includes:The original character string after being encoded by base64;
It is described to be decoded the encoded original character string, the original character string is generated, including:
The encoded original character string is decoded by base64, generates the original character string;
It is described according to the parameter current object, generate the corresponding encoded substitute character of each target object
String, including:
According to the parameter current object, the corresponding volume encoded by base64 of each target object is generated
The substitute character string of code.
In embodiments of the present invention, various codings can be realized by base64 codings, correspondingly, various decodings pass through
Base64 decodes to realize.
As shown in Fig. 2, an embodiment of the present invention provides a kind of method for realizing script argument, this method may include with
Lower step:
Step 201:It is determined from the script to be parameterized encoded by base64 through the original of base64 codings
Character string, wherein original character string includes parameterized object.
Specifically, it can be obtained from action.c files by the base64 scripts to be parameterized encoded.
For example, it is by the base64 original character strings encoded:
[dXNlcmNvZGU6emhhbmdzYW4scGFzc3dvcmQ6MTIzNDU2LHVzZXJuYW1lOj8/]。
Step 202:The corresponding at least one target object of getting parms object, wherein the character of each target object
Number is identical as the number of characters of parameterized object.
For example, parameterized object is [zhangsan], and the number of characters of each target object is 8, this is at least one
Target object may include:chenxing、xiaoming.
Step 203:It will be decoded by base64 by the base64 original character strings encoded, generate original character string.
For example, the original character string obtained after decoding is:[usercode:zhangsan,password:123456,
username:Zhang San].
Step 204:Each parameterized object is identified from original character string.
For example, it is identified from original character string each [zhangsan].
Step 205:For each parameterized object, execute:From encoded original character string, parameter current is identified
Change the corresponding encoded target string of object;According to parameter current object, generate that each target object is corresponding have been compiled
The substitute character string of code;Encoded target string in encoded script to be parameterized is replaced with into alternative parameter,
In, alternative parameter can be at least one encoded substitute character string of value any one.
Specifically, alternative parameter can be realized by the format of " parameter _ number ".Number can be according to the sequence of parameter
To determine.
For example, the corresponding alternative parameter of first parameterized object is:[name_01].By first parametrization pair
As corresponding encoded target string replaces with [name_01].
Specifically, the corresponding all encoded substitute character strings of parameter current object can be saved in name_
It, will be under the storage to the store path of encoded script to be parameterized of name_01.dat files in 01.dat files.The name_
01.dat files are the corresponding Parameter File of parameter current object.
For example, to [e:Chenxing, p] it is encoded by base64, generate [e:Chenxing, p] it corresponding has compiled
The substitute character string of code.
To [e:Xiaoming, p] it is encoded by base64, generate [e:Xiaoming, p] corresponding encoded replacement word
Symbol string.
In addition, this method can also include:According to the foot each parameterized object corresponding Parameter File and be generated in advance
This implementation strategy generates configuration code, configuration code is appended in the script argument configuration file of script to be parameterized.
For example, which can be as follows:
[parameter:【name_03】]
Delimiter=", "
ParamName="【name_03】"
TableLocation=" Local "
ColumnName=" Col 1 "
Table="【name_03】.dat"
GenerateNewVal="【EachIteration】/【EachOccurrence】/【Once】"
Type=" Table "
Value_for_each_vuser="【Numerical value】/"
OriginalValue=" "
Auto_allocate_block_size="【1】/【0】"
SelectNextRow="【Sequential】/【Random】/【Unique】"
StartRow=" 1 "
OutOfRangePolicy="【AbortVuser】/【ContinueCyclic】/【ContinueWithLast】"
After the completion of the operation executes, script implementation strategy is also provided with completion, and entire parametrization is fully completed, without carrying out two
Secondary setting.
The embodiment of the present invention can be realized by following code:
Through the embodiment of the present invention, it can realize that parameter generates, parameter is replaced, the automation of parameter setting, settle at one go,
Without secondary setting;Save parameter lookup, the time of replacement can greatly carry especially when there are many quantity of parametrization
Working efficiency is risen, test resource is saved.
As shown in Figure 3, Figure 4, an embodiment of the present invention provides a kind of devices for realizing script argument.Device embodiment can
By software realization, can also be realized by way of hardware or software and hardware combining.For hardware view, such as Fig. 3 institutes
Show, is a kind of hardware structure diagram of equipment where a kind of device for realizing script argument provided in an embodiment of the present invention, in addition to
Except processor shown in Fig. 3, memory, network interface and nonvolatile memory, the equipment in embodiment where device is logical
It often can also include other hardware, such as be responsible for the forwarding chip of processing message.For implemented in software, as shown in figure 4, making
It is by the CPU of equipment where it by corresponding computer journey in nonvolatile memory for the device on a logical meaning
Sequence instruction reads what operation in memory was formed.A kind of device for realizing script argument provided in this embodiment, including:
Originally determined unit 401, for determining encoded original character string from encoded script to be parameterized,
In, the original character string includes parameterized object;
Acquiring unit 402, for obtaining the corresponding at least one target object of the parameterized object;
Original decoded unit 403 generates the original character for the encoded original character string to be decoded
String;
Recognition unit 404, for identifying each parameterized object from the original character string;
Parameterized units 405, for for each parameterized object, executing:
From encoded original character string, the corresponding encoded target string of parameter current object is identified;
According to the parameter current object, the corresponding encoded substitute character string of each target object is generated;
Encoded target string in script to be parameterized described in will be encoded replaces with alternative parameter, wherein
The alternative parameter can be at least one encoded substitute character string of value any one.
In an embodiment of the present invention, the parameterized units, it is described from encoded original character string executing, know
When not going out the corresponding encoded target string of parameter current object, it is specifically used for:
In the original character string, determine the first character of the original character string to the parameter current object
Previous character the first number of characters;
The first remainder behind first number of characters divided by 3 is determined, using first remainder as the digit taken forward;
It regard the sum of number of characters of the digit taken forward and the parameter current object as the second number of characters;
Determine the second remainder behind second number of characters divided by 3;
According to second remainder, the digit taken backward is determined, wherein described to take backward when second remainder is 0
Digit be 0, when second remainder be 1 when, the digit taken backward be 2, when second remainder be 2 when, it is described to
The digit taken afterwards is 1;
According to formula one, determine that the first character of the target string is m-th of encoded original character string
Character, wherein the formula one is:
Wherein, d is first number of characters, and q is the digit taken forward;
According to formula two, determine that the length of the target string is n, wherein the formula two is:
Wherein, c is the number of characters of the parameter current object, and h is described to be taken backward
Digit;
According to the m and the n, determine that the parameter current object is corresponding from encoded original character string
The target string of coding.
In an embodiment of the present invention, the parameterized units, it is described according to the parameter current object executing, it is raw
When encoded substitute character string corresponding at each target object, it is specifically used for:
It is adjacent with the parameter current object before determining the parameter current object in the original character string
Q character constitute the first character string;
In the original character string, determine after the parameter current object with the parameter current object phase
The second character string that h adjacent character is constituted;
For each target object, execute:
By first character string, current target object and second character string, it is combined into third character string, wherein
The third character string is from left to right first character string, the current target object and second character string successively;
The third character string is encoded, the corresponding encoded substitute character of the current target object is generated
String;
Wherein, the number of characters of each target object is identical as the number of characters of the parameterized object.
In an embodiment of the present invention, which further comprises:Storage unit, for preserving script implementation strategy;
The parameterized units are further used for generating each mesh according to the parameter current object described
After marking the corresponding encoded substitute character string of object, execute:
For each parameterized object, the corresponding each encoded substitute character string of parameter current object is write
Enter into the corresponding Parameter File of the parameter current object;
According to each corresponding Parameter File of parameterized object and the script implementation strategy, configuration code is generated;
The configuration code is appended in the script argument configuration file of the script to be parameterized, so that described wait joining
Numberization script can be run according to each corresponding Parameter File of character string to be replaced and the script implementation strategy.
In an embodiment of the present invention, the encoded script to be parameterized includes:Institute after being encoded by base64
State script to be parameterized;
The encoded original character string includes:The original character string after being encoded by base64;
The original decoded unit, for decoding the encoded original character string by base64, described in generation
Original character string;
The parameterized units, it is described according to the parameter current object executing, generate each target object
When corresponding encoded substitute character string, it is specifically used for:
According to the parameter current object, the corresponding volume encoded by base64 of each target object is generated
The substitute character string of code.
The contents such as the information exchange between each unit, implementation procedure in above-mentioned apparatus, due to implementing with the method for the present invention
Example is based on same design, and particular content can be found in the narration in the method for the present invention embodiment, and details are not described herein again.
An embodiment of the present invention provides a kind of readable mediums, including execute instruction, when the processor of storage control executes
It is described when executing instruction, the storage control execute it is provided in an embodiment of the present invention any one realize the side of script argument
Method.
An embodiment of the present invention provides a kind of storage controls, including:Processor, memory and bus;
The memory is executed instruction for storing, and the processor is connect with the memory by the bus, when
When the storage control operation, the processor executes executing instruction for the memory storage, so that the storage controls
The method that device executes any one realization script argument provided in an embodiment of the present invention.
The each embodiment of the present invention at least has the advantages that:
1, in embodiments of the present invention, original character string, getting parms are decoded from encoded original character string
The corresponding at least one target object of object, identifies that each parameterized object is corresponding from encoded script to be parameterized
It is corresponding to replace each parameterized object using the corresponding alternative parameter of each parameterized object for encoded target string
The target string of coding realizes that the parametrization of script to be parameterized, whole process are automatically performed, and is participated in without artificial,
Improve the speed for realizing script argument.
2, through the embodiment of the present invention, it can realize that parameter generates, parameter is replaced, the automation of parameter setting, a step arrives
Position is not necessarily to secondary setting;The time that parameter is searched, replaced is saved, it, can be greatly especially when there are many quantity of parametrization
Working efficiency is promoted, test resource is saved.
It should be noted that herein, such as first and second etc relational terms are used merely to an entity
Or operation is distinguished with another entity or operation, is existed without necessarily requiring or implying between these entities or operation
Any actual relationship or order.Moreover, the terms "include", "comprise" or its any other variant be intended to it is non-
It is exclusive to include, so that the process, method, article or equipment including a series of elements includes not only those elements,
But also include other elements that are not explicitly listed, or further include solid by this process, method, article or equipment
Some elements.In the absence of more restrictions, the element limited by sentence " including one ", is not arranged
Except there is also other identical factors in the process, method, article or apparatus that includes the element.
One of ordinary skill in the art will appreciate that:Realize that all or part of step of above method embodiment can pass through
The relevant hardware of program instruction is completed, and program above-mentioned can be stored in computer-readable storage medium, the program
When being executed, step including the steps of the foregoing method embodiments is executed;And storage medium above-mentioned includes:ROM, RAM, magnetic disc or light
In the various media that can store program code such as disk.
Finally, it should be noted that:The foregoing is merely presently preferred embodiments of the present invention, is merely to illustrate the skill of the present invention
Art scheme, is not intended to limit the scope of the present invention.Any modification for being made all within the spirits and principles of the present invention,
Equivalent replacement, improvement etc., are included within the scope of protection of the present invention.