VS2010 负载测试:如何执行在每次负载测试之前运行一次的自定义操作 [英] VS2010 Load Testing: How can I perform custom action that is run once prior to each load test

查看:27
本文介绍了VS2010 负载测试:如何执行在每次负载测试之前运行一次的自定义操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我需要在运行每个负载测试之前重新启动特定服务,并且重新启动本身没有问题.我已经研究了一段时间,但还没有找到一种方法来放置一些操作或脚本,或者只是另一个负载测试,所以我可以确定它是在每次负载测试之前执行的,并且每次负载测试只执行一次.

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.

推荐答案

创建LoadTest Plugin 并使用 LoadTestStarting 事件调用重新启动服务的方法.

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

然后在负载测试编辑器中右键单击根目录并选择 Add Load Test Plug-in... 将插件添加到您的 Load Test.

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.

这篇关于VS2010 负载测试:如何执行在每次负载测试之前运行一次的自定义操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆