How to: Use the Web Performance Test API
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.
Requirements
- Visual Studio Ultimate
To use the WebTesting namespace
Open a Web performance and load test project that contains a Web performance test.
For more information, see Creating and Editing Web Performance Tests.
Add a Visual C# or a Visual Basic class library project to your test solution.
Add a reference in the Web performance and load test project to the class library project.
Add a reference to the Microsoft.VisualStudio.QualityTools.WebTestFramework DLL in the class library project.
In the class file that is located in the class library project, add a using statement for the Microsoft.VisualStudio.TestTools.WebTesting namespace.
Create a class that implements the WebTestPlugin interface.
Build the project.
Add the new Web performance test plug-in by using the Web Performance Test Editor:
Choose Add Web Test Plug-in on the toolbar.
The Add Web Test Plug-in dialog box is displayed.
Under Select a plug-in, select your Web performance test plug-in class.
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.
Choose OK.
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: 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