Automated testing in VS2010 (5)--web performance test

Source: Internet
Author: User

Original address: http://www.cnblogs.com/heqichang/archive/2011/11/20/2256478.html

Class Zeal here: http://www.cnblogs.com/heqichang/category/315226.html

Then the last article, this time I will elaborate on the performance test in the editing window of the various functions and operations.

Last time we talked about the tree structure in our editing window, each layer has different property settings.

    • Root level: Can be said to be a Web performance test entry point, such as: You can set up user authentication, agent, or to add some descriptive information for this test;
    • Request level: For each individual request recorded in the Web performance test, you can set user think times (think time), request mode (get or post) or set cache, etc.
    • Request Parameter Level: Here is the parameter setting for each request, where you can set the URL encoding, the value, and the name.

Here all the property settings you can see in the Properties window description, if you do not understand, you can view the MSDN Help, all the properties are under the Microsoft.VisualStudio.TestTools.WebTesting namespace.

Extraction rule (Extraction rules)

In VS we can extract some useful data from the website using the function of extracting rules.

Typically, almost all Web sites have dependencies between their pages, for example, your next request relies on some data from your last request response. So the extraction rule is a feature that allows you to extract the data you need from the response data and save it for your next request or when you need it later. It saves the data in a context parameter that you can use in a global environment.

Several extraction rules have been built for us within the VS2010,

For an explanation of the built-in extraction rules, see here. If the built-in extraction rules don't meet your needs, you can also customize your own extraction rules.

Here I borrow Baidu (steal a lazy ^_^) to do a demo, see How to use extraction rules.

According to the previous article, first use recorder to open Baidu, and then casually search for a thing (I Baidu's James), finally click Stop, will generate the following data in VS:

Now we right-click on the first request node to add an extraction rule, because I'm going to fetch the value from the first request response back, as follows:

The extraction rule settings are as follows:

Through the above settings, I will Baidu page, the value of the search button ("Baidu a Bit") is extracted, then the Baidu parameter in the following program will always save this value. It is accessed in a manner similar to that of Key-value. We run this test and we can see the information we extracted in the results.

We can use the saved information for the next request or any subsequent request, for example, we can modify the value that needs to be searched in the second request:

By right-clicking the property and then re-binding it to the Baidu property in the Value property, we also need to note that the value we extracted earlier is Chinese, so we need to set the URL encoding to ture. Finally we rerun the test to see the results:

Here we can see that our second search is not James, but "Baidu."

Validation rule (Validation rules)

Many websites have some verification programs to verify that the input or output is correct, such as: The user name cannot contain special characters, password must not be less than 6 characters or the correct email format and so on.

Validation rules This function is to verify that the response data contains the expected information, if any, this request can pass, otherwise it will fail.

My VS2010 also has several validation rules built in:

For an explanation of the built-in validation rules, see here. If the built-in validation rules don't meet your needs, you can also customize your own validation rules.

Validation rules are used in much the same way as extraction rules, but it's just a matter of validating, not saving your data. It is important to note, however, that as the validation rules increase, the performance testing and testing time of the site will be affected, especially when it comes to stress testing, and it is also necessary to decide what data is critical and needs to be verified. Of course, VS also provides the level of setting validation rules to mitigate these effects.

Related articles:

Automation Testing in VS2010 (4)--web performance test (1)

Automated testing in VS2010 (3)-data-driven unit testing

Automated testing in VS2010 (2)--unit test

Automated testing in VS2010 (1) test management tools in--vs2010

Automated Tests in VS2010 (5)--web performance test

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.