Reputation: 398
Is there an elegant way to setup StartUp and Cleanup methods to run for a Load Test in Visual Studio ?
I have a Controller - Agents system for load testing and I need to find a way to run a method before the Test runs and after it finishes but only in the controller.
Upvotes: 3
Views: 1260
Reputation: 14076
Plugins can be written for load tests. Basically the plugin provides code to be run during the initialisation of the test run. That code can attach event handlers for the following and hence the test can be manipulated in many ways. (List of events copied from here.)
LoadTestStarting, LoadTestFinished, LoadTestWarmupComplete, TestStarting, TestFinishedTestSelected, ThresholdExceeded, HeartBeat, and LoadTestAborted.
See this Microsoft page (and the pages it links to) for more details on writing load test plugins.
Visual Studio tests also use a ".testsettings" file to specify several aspects of the test. This file allows set-up and clean-up scripts to be specified. These can be seen in the image below "Configure the test controller and roles for remote data collection and execution" and in the "Test Settings: Setup and Cleanup Scripts" parts of this Microsoft page.
Not part of the question, but added for completeness. Plugins can also be written for the web tests. Two forms are provided, web test request plugins and http://msdn.microsoft.com/en-us/library/ms243191(v=vs.110).aspx plugins.
See also this Stackoverflow question VS2010 Load Testing: How can I perform custom action that is run once prior to each load test
Upvotes: 2