Loadrunner11 script optimization for mobile performance testing

Source: Internet
Author: User

Script optimization of test steps (scripts)

See here, is not wondering whether the recorded script also needs optimization, the answer is yes.

Optimization Summary

Script optimizations include inserting comments (Comment), inserting transactions (Transaction), inserting checkpoints (check), inserting collection points (rendezvous), Scripting Parameterization (Parameter), association Techniques (Correlation), and so on.

To open Vugen, the settings are as follows

Go to the Scripting page (the Script button at the top) to see the script that was recorded to the Action section, as shown in

The above is my recorded optimized login module script, learned the programming language can probably know, LR script is composed of some functions, lr_output_message (print output in the log, similar to the printf function in C), Web_custom_request (Request function, is to simulate the user Click button action, click once to submit this request), WEB_REG_SAVE_PARAM_EX (registration function, popular point is to find and save specific data in the server return data) and so on.

Anyway, after the recording is successful, you first have to play back the script to see if there are any problems, no problem, according to the needs of the real environment for scripting optimization.

Insert Comment (Comment)

Insert comments in order to make the script easy to understand, very simple, single line in front Plus//CAN, multiline comments with/* .... (Here is the script) ... * *.

Insert Transaction (Transaction)

Inserting a transaction is also quick, which is to determine the time of the operation, remembering that the transaction is inserted after the collection point and that it is paired, such as Lr_start_transaction ("login") and lr_end_transaction ("login", Lr_auto), the name of the thing is the same, In general, the end of the lr_auto of things to automatically determine whether things are successful, did not encounter the error page is basically successful, so it needs to be judged by checkpoints.

Inserting a collection point (rendezvous)

Insertion point (lr_rendezvous), generally do concurrency testing is required to set points, such as the concurrent landing, insert can be set in the scene design, when the number of virtual users set to run all to the collection point, and then run concurrently, scripts such as:

Insert Checkpoint (check)

Above said things need to check the point to judge, take the login, the general login success will be displayed on the home page "welcome you, XX users", is not to find "welcome you" three words to indicate the success of the login, so check point so come. Auto Add I won't say it, manually insert the following:

Web_reg_find (

"Text=\" respcode\ ": \" 0\ "",

"Savecount=ok_count",

last);

Web_custom_request (

....//omission of content.

last);

Lr_output_message (lr_eval_string ("Ok_count find Respcode Value and count"));

if (Atoi (lr_eval_string ("{ok_count}")) >0)

Lr_output_message ("-----------------------------Login successfully! -----------------------------", Lr_pass);

Else

Lr_output_message ("-----------------------------Login failed!------------------------------", lr_fail);

Checkpoint commonly used functions: Web_reg_find, the data returned from the server lookup, text is the content of the lookup, Savecount is the count variable name, here to determine whether the value of Savecount is greater than 0, more than 0 means to find the return value, execution Lr_pass, the thing succeeds, That means the login was successful.

Note: lr_eval_string ("{ok_count}") Gets the value of the return parameter Ok_count, type Char,atoi ("{lr_eval_string}") to convert the character type to an integer type.

Manual Association (Correlation)

In the replay script is always unsuccessful, find the reason, is the problem of login verification code, this is the server returned, the wrong can not log on. Can not lose their own, development and can not be blocked, how to deal with it? For dynamic Data returned by the server, it is called Association technology to find and save in one parameter. The same automatic association is not said, the manual association is as follows:

WEB_REG_SAVE_PARAM_EX (

"Paramname=csrule_1",

"Lb=\" code\ ":",

"Rb=}}",

"Ordinal=1",

"Saveoffset=1",

"Savelen=6",

Search_filters,

last);

View the response log as follows: "Mobilerespheader": {"Respcode": "$", "Respdesc": "Contact Radiation Functions"}, "Mobilerespbody": {"data": {"code": "MKLJ39"}}

The result of the lookup is csrule_1= MKLJ39, followed by csrule_1 instead of the verification code.

Commonly used association functions: Web_reg_save_param_ex,csrule_1 is a custom parameter name, LB,RB is the left and right boundary, used to locate the data that is found, ordinal refers to the location of the first few occurrences of the content, Saveoffset refers to the number of strings found from the beginning of the interception, Savelen refers to how much length of the value, the other even fixed format, pay attention!!! The colon "must be preceded by a backslash" \ "

Scripting Parameterization (Parameter)

Here is the login account of the parameterization, directly in the account at the right click-replace with a parameter input name, type can refer to the data, is generally file.

Parameterized data can be entered manually, as well as DAT files, and can be imported from a database.

After the account parameterization, right click-parameter Properties ... Enter the parameterized setting interface, the specific parameter reference, to pay attention to the image of the order of values and policy settings, combined together a total of 9 ways.

Just remember that the select Next row row is set for the virtual user of the scene run, Vugen playback does not work, select sequential, each user from the first row of parameters to start the order, the Update Value on the line is set for the parameters of the script, select each iteration, the parameters of a single user are the same in the same iteration, no matter how many parameters you have.

The above is the script optimization of the approximate process, not carefully written, for reference, before the last save do not forget to replay the script Oh!

Loadrunner11 script optimization for mobile performance testing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.