How to: Use the Web Test API

You can write code for your Web tests. The Web test API is used to create coded Web tests, Web 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 tests.

You can also use the Web test API to programmatically create and save declarative Web tests. To do this, use the T:Microsoft.VisualStudio.TestTools.WebTesting.DeclarativeWebTest and T:Microsoft.VisualStudio.TestTools.WebTesting.DeclarativeWebTestSerializer classes.


Use the object browser to examine the Microsoft.VisualStudio.TestTools.WebTesting namespace. Both the 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: Create a Load Test Plug-In.

Using the Web test API

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

    For more information, see How to: Create a Test Project.

  2. Add a 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 located in the class library project, add a using statement for the Microsoft.VisualStudio.TestTools.WebTesting namespace.

  6. Implement any of the core classes in the namespace in the class library project. For an example implementation of WebTestPlugin, see How to: Create a Web Test Plug-In. You can write the rest of the code that you need, and then build the project.

  7. Run your Web test.

See Also


How to: Use the Load Test API

How to: Create a Web Test Plug-In