基本上,我需要在运行每个负载测试之前重新启动特定服务,并且重新启动本身没有问题。我已经研究了一段时间,但还没有找到一种方法来放置一些操作或脚本或只是另一个负载测试,以便我可以确保它在每次负载测试之前执行,并且每次负载测试仅执行一次。
任何有关如何使其以这种方式运行的想法都值得赞赏。
最佳答案
创建 LoadTest Plugin并使用 LoadTestStarting
事件调用重新启动服务的方法。
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)
{
}
}
然后在负载测试编辑器中右键单击根目录并选择添加负载测试插件...
将插件添加到负载测试
。
关于visual-studio-2010 - VS2010负载测试: How can I perform custom action that is run once prior to each load test,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9990917/