Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Coding a custom validation rule for a web performance test

 

You can create your own validation rules. To do this, you derive your own rule class from a validation rule class. Validation rules derive from the ValidationRule base class.

Visual Studio Enterprise provides some predefined validation rules. For more information, see Using Validation and Extraction Rules in Web Performance Tests.

System_CAPS_ICON_note.jpg Note

You can also create custom extraction rules. For more information, see Create custom code and plug-ins for load tests.

Requirements

  • Visual Studio Enterprise

To create custom validation rules

  1. Open a Test Project that contains a Web performance test.

  2. (Optional) Create a separate Class library project in which to store your validation rule.

    System_CAPS_ICON_important.jpg Important

    You can create the class in the same project that your tests are in. However, if you want to reuse the rule, it is better to create a separate Class library project in which to store your rule. If you create a separate project, you must complete the optional steps in this procedure.

  3. (Optional) In the Class library project, add a reference to the Microsoft.VisualStudio.QualityTools.WebTestFramework DLL.

  4. Create a class that derives from the ValidationRule class. Implement the Validate and RuleName members.

  5. (Optional) Build the new Class library project.

  6. (Optional) In the Test Project, add a reference to the Class library project that contains the custom validation rule.

  7. In the Test Project, open a Web performance test in the Web Performance Test Editor.

  8. To add the custom validation rule to a Web performance test request, right-click a request and select Add Validation Rule.

    The Add Validation Rule dialog box appears. You will see your custom validation rule in the Select a rule list, together with the predefined validation rules. Select your custom validation rule and then choose OK.

  9. Run your Web performance test.

The following code shows an implementation of a custom validation rule. This validation rule mimics the behavior of the predefined Required Tag validation rule. Use this example as a starting point for your own custom validation rules.

System_CAPS_ICON_warning.jpg Warning

Public properties in the code for a custom validator cannot have null values.

No code example is currently available or this language may not be supported.

ValidationRule
Microsoft.VisualStudio.TestTools.WebTesting.Rules
ValidateFormField
ValidationRuleFindText
ValidationRuleRequestTime
ValidationRuleRequiredAttributeValue
ValidationRuleRequiredTag
Using Validation and Extraction Rules in Web Performance Tests
How to: Add a Validation Rule to a Web Performance Test
Adding validation and extraction rules to a web performance test
Coding a custom extraction rule for a web performance test

Show: