Export (0) Print
Expand All

Using Validation and Extraction Rules in Web Performance Tests

Validation rules help verify that a Web application is working correctly by validating the existence of text, tags, or attributes on the page returned by a Web request. Validation rules can also verify the time that it takes a request to finish, and the existence of form fields and their values.

Extraction rules help verify that a Web application is working correctly by extracting data from the responses to Web requests. Extraction rules store results in the test context as name value pairs. Extraction rules can extract form fields, text, attributes, headers, regular expressions, and hidden fields.

This topic describes how to create and use validation and extraction rules in Web performance tests.

Predefined Validation Rules

Visual Studio Ultimate includes the following predefined validation rules:

Validation Rule Type

Description

Selected Option

Validates that the specified option in the HTML 'select' tag is selected.

Tag Inner Text

Validates that the specified expected inner text exists within the specified HTML tag.

For example, you can validate that specific inner text exist in a list box where the option text is stored in inner text rather than an attribute:

<select name="myListBox">
        <option>Car</option>
        <option>Train</option>
        <option selected="selected">Ship</option>
        <option>Airplane</option>
    </select>
    </form>

In this case, if you wanted to verify that "Airplane" exists in myListBox, you would set the following properties for the validation rule:

  • Expected Inner Text to Airplane.

  • Tag Name to option.

Response Time Goal

Validates that the response time for the request is less than or equal to the response time goal as specified on the request. Response time goals of zero will be ignored.

Form Field

Verifies the existence of a form field that has a specified name and value.

Find Text

Verifies the existence of specified text in the response. For more information about using the find text validation rule, see Walkthrough: Adding Validation and Extraction Rules to a Web Performance Test.

Maximum Request Time

Verifies that the request finishes within a specified amount of time.

Required Attribute Value

Verifies the existence of a specified HTML tag that contains an attribute that has a specified value.

Required Tag

Verifies the existence of a specified HTML tag in the response.

Response URL

Validates that the response URL, after redirects are followed, is the same as the recorded response URL. QueryString parameters are ignored.

Custom Validation Rules

Visual Studio Ultimate provides predefined validation rules in the form of classes in the Microsoft.VisualStudio.TestTools.WebTesting.Rules namespace. However, you can create your own custom validation rules by deriving from the ValidationRule class. For more information, see How to: Create a Custom Validation Rule for a Web Performance Test.

Impact of Validation Rules on Load Testing

Execution of validation rules has an impact on performance in load testing. To reduce the performance impact, use the Validation Level of a request to control which validation rules are used in a specific load test. You can set the validation level of each rule to Low, Medium, or High. Typically, the higher you set the validation level, the slower your test will run.

Setting the Validation Level of a rule in a request determines when that validation rule is used in a load test. For example, setting it to High means that the rule is executed only when the load test validation level is set to high.

Load Test Validation level

Description of Request settings used

Low

Invoke only rules with a setting of Low

Medium

Invoke rules with a setting of Low and Medium

High

Invoke all rules - Low, Medium, and High

The ability to set the rule levels in both the Web performance test request and the load test setting gives you flexibility in your testing. Setting a load test setting to Low executes the fewest rules and can be used for heavy load test and stress runs. Setting a load test setting to High executes the most rules and should be used when validation is more important than maximum throughput.

Extraction rules help verify that a Web application is working correctly by extracting data from the responses to Web requests. Extraction rules store results in the test context as name value pairs. Extraction rules can extract form fields, text, attributes, headers, regular expressions, and hidden fields.

Validation rules are similar to extraction rules, but instead of extracting data, they validate the existence of data.

Predefined Extraction Rules

Visual Studio Ultimate includes the following predefined extraction rules:

Extraction Rule Type

Description

Selected Option

Extract the selected text in a list or combo box.

Tag Inner Text

Extracts the inner text from the specified HTML tag.

Extract Attribute Value

Extract the value of an attribute from a specified HTML tag. For more information about using the extract attribute value rule, see Walkthrough: Adding Validation and Extraction Rules to a Web Performance Test.

Extract Form Field

Extract the value of a specified form field in the response.

Extract HTTP Header

Extract the value of an HTTP header.

Extract Regular Expression

Extract text from the response matching a regular expression.

Extract Text

Extract text from the response.

Extract Hidden Fields

Extract all hidden fields from the response.

Custom Extraction Rules

Visual Studio Ultimate provides predefined extraction rules in the form of classes in the Microsoft.VisualStudio.TestTools.WebTesting.Rules namespace. However, you can create your own custom extraction rules by deriving from the ExtractionRule class. For more information, see How to: Create a Custom Extraction Rule for a Web Performance Test.

Tasks

Associated Topics

Adding validation rules in a Web performance test: Add and configure a validation rules in your Web performance test to help verify that a Web application is working correctly by validating the existence of text, tags, or attributes on the page returned by a Web request. Validation rules can also verify the time it takes a request to finish, and the existence of form fields and their values. Validation rules can be also be specifically used on inner text and on select targets.

You can also add validation rules to Web performance tests at the test-level which fires on every request in the test.

Adding extraction rules in your Web performance test: Add and configure an extraction rules to help verify that a Web application is working correctly by extracting data from the responses to Web requests. Extraction rules store results in the test context as name value pairs. Extraction rules can extract form fields, text, attributes, headers, regular expressions, and hidden fields.

Creating your own custom validation and extraction rules: In addition to using the validation and extraction rules that are predefined in Microsoft Visual Studio Ultimate, you can create your own rules by deriving them from either the ValidationRule or the ExtractionRule base classes. After you create a custom validation or extraction rule, you can add it to a Web performance test request.

Community Additions

ADD
Show:
© 2014 Microsoft