Rob Bowman
Rob Bowman

Reputation: 8741

VS2010 Load Test Run Prepare and Verify Once

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?

Upvotes: 2

Views: 250

Answers (1)

chaliasos
chaliasos

Reputation: 9793

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
    }
}

Upvotes: 3

Related Questions