2

我们有一个运行 100 个并发用户的负载测试。我们还有“准备”和“验证”测试,我们希望在整个负载测试的开始和结束时只运行一次——而不是针对负载测试中的每个模拟用户 (*100)。

谁能建议最简单的配置方法?

4

1 回答 1

3

您可以创建一个负载测试插件并使用LoadTestStarting&LoadTestFinished事件来调用您想要的方法:

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
    }
}
于 2012-06-08T10:47:36.637 回答