Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
665 views
in Technique[技术] by (71.8m points)

visual studio 2010 - VS2010 Load Testing: How can I perform custom action that is run once prior to each load test

Basically, I need to restart particular service prior to each load test being run and there is no problem with the restart itself. I've researched for a while and haven't found a way to put some action or script or just another load test, so that I can be sure it is performed before each load test and only one time per load test.

Any ideas regarding how to make it behave this way are appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Create a LoadTest Plugin and use the LoadTestStarting event to call a method that restarts your service.

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)
    {
        // Restart your service
    }

    void loadTest_LoadTestFinished(object sender, System.EventArgs e)
    {
    }
}

Then in the Load Test Editor right click on the root and select Add Load Test Plug-in... to add the Plug-In to your Load Test.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...