How to: Use the Load Test API
This topic applies to:
Visual Studio Ultimate
Visual Studio Premium
Visual Studio Professional
Visual Studio Express
Visual Studio Ultimate supports load test plug-ins which can control or enhance a load test. Load test plug-ins are user defined classes which implement the ILoadTestPlugin interface found in the Microsoft.VisualStudio.TestTools.LoadTesting namespace. Load test plug-ins allow for custom load test control, such as, aborting a load test when a counter or error threshold is met. Use the properties on the LoadTest class to get or set load test parameters from user defined code. Use the events on the LoadTest class to attach delegates for notifications when the load test is running.
Use the object browser to examine the Microsoft.VisualStudio.TestTools.LoadTesting namespace. Both the Visual C# and Visual Basic editors offer IntelliSense support for coding with the classes in the namespace.
To use the LoadTesting namespace
Open a Test Project that contains a load test.
For more information, see Creating and Editing Load Tests.
Add a Visual C# or a Visual Basic class library project to your test solution.
Add a reference in the test project to the class library project.
Add a reference to the Microsoft.VisualStudio.QualityTools.LoadTestFramework dll in the Class Library project.
In the class file located in the class library project, add a using statement for the Microsoft.VisualStudio.TestTools.LoadTesting namespace.
Create a public class that implements the ILoadTestPlugin interface.
Build the project.
Add the new load test plug-in using the Load Test Editor:
Right-click the root node of the load test and then click Add Load Test Plug-in.
The Add Load Test Plug-in dialog box is displayed.
In the Properties for selected plug-in pane, set the initial values for the plug-in to use at run time.
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 load test plug-in properties later using the Properties window.
Run your Load test.