How to: Use the Load Test API
Visual Studio Enterprise 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.
- Visual Studio Enterprise
Open a Web performance and load test Project that contains a load test.
For more information, see Create and run a load test.
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.LoadTestFramework DLL in the Class Library project.
In the class file located in the class library project, add a
usingstatement 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 choose 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.