问题
We have a load test that runs of 100 concurrent users. We also have "Prepare" and "Verify" tests that we'd like to run just once at the beginning and end of the whole load test - NOT for each emulated user (*100) in the load test.
Can anyone please advise the easiest way to configure this?
回答1:
You can create a Load Test Plug-In and use the LoadTestStarting
& LoadTestFinished
events to call the methods you want:
public class Plugin : ILoadTestPlugin
{
private LoadTest _loadTest;
public void Initialize(LoadTest loadTest)
{
_loadTest = loadTest;
_loadTest.LoadTestStarting += new System.EventHandler(loadTest_LoadTestStarting);
_loadTest.LoadTestFinished += new System.EventHandler(loadTest_LoadTestFinished);
}
void loadTest_LoadTestStarting(object sender, System.EventArgs e)
{
//call your prepare method
}
void loadTest_LoadTestFinished(object sender, System.EventArgs e)
{
//call your verify method
}
}
来源:https://stackoverflow.com/questions/10946556/vs2010-load-test-run-prepare-and-verify-once