Share via


How to: Use the Web Performance Test API

This topic applies to:

Visual Studio Ultimate

Visual Studio Premium

Visual Studio Professional 

Visual Studio Express

Topic applies Topic does not apply Topic does not apply Topic does not apply

You can write code for your Web performance tests. The Web performance test API is used to create coded Web performance tests, Web performance test plug-ins, request plug-ins, requests, extraction rules, and validation rules. The classes that make up these types are the core classes in this API. The other types in this API are used to support creating WebTest, WebTestPlugin, WebTestRequestPlugin, WebTestRequest, ExtractionRule, and ValidationRule objects. You use the Microsoft.VisualStudio.TestTools.WebTesting namespace to create customized Web performance tests.

You can also use the Web performance test API to programmatically create and save declarative Web performance tests. To do this, use the DeclarativeWebTest and DeclarativeWebTestSerializer classes.

Tip

Use the object browser to examine the Microsoft.VisualStudio.TestTools.WebTesting namespace. Both the Visual C# and Visual Basic editors offer IntelliSense support for coding with the classes in the namespace.

You can also create plug-ins for load tests. For more information, see How to: Use the Load Test API and How to: Create a Load Test Plug-In.

To use the WebTesting namespace

  1. Open a test project that contains a Web performance test.

    For more information, see Creating and Editing Web Performance Tests.

  2. Add a Visual C# or a Visual Basic class library project to your test solution.

  3. Add a reference in the test project to the class library project.

  4. Add a reference to the Microsoft.VisualStudio.QualityTools.WebTestFramework dll in the class library project.

  5. In the class file that is located in the class library project, add a using statement for the Microsoft.VisualStudio.TestTools.WebTesting namespace.

  6. Create a class that implements the WebTestPlugin interface.

  7. Build the project.

  8. Add the new Web performance test plug-in by using the Web Performance Test Editor:

    1. Click Add Web Test Plug-in on the toolbar.

      The Add Web Test Plug-in dialog box is displayed.

    2. Under Select a plug-in, select your Web performance test plug-in class.

    3. In the Properties for selected plug-in pane, set the initial values for the plug-in to use at run time.

      Note

      You can expose as many properties as you want from your plug-ins; just make them public, settable, and of a base type such as Integer, Boolean, or String. You can also edit the Web performance test plug-in properties later by using the Properties window.

    4. Click OK.

  9. Run your Web performance test.

    For an example implementation of WebTestPlugin, see How to: Create a Web Performance Test Plug-In.

See Also

Tasks

How to: Use the Load Test API

How to: Create a Web Performance Test Plug-In

Reference

Microsoft.VisualStudio.TestTools.WebTesting

Other Resources

Creating and Using Custom Plug-ins for Load and Web Performance Tests