2012-04-03 115 views
2

基本上,我需要在每次負載測試運行之前重新啓動特定服務,並且重啓本身沒有問題。我已經研究了一段時間,還沒有找到一種方法來放置一些動作或腳本或者只是另一個負載測試,以便我可以確定它在每次負載測試之前執行,並且每次負載測試只執行一次。VS2010負載測試:如何執行在每次負載測試之前運行一次的自定義操作

有關如何使其表現這種方式的任何想法,讚賞。

回答

2

創建一個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) 
    { 
    } 
} 

然後在負載測試編輯器右鍵單擊根並選擇Add Load Test Plug-in...添加插件您Load Test

0

另一種選擇,特別是如果你無論如何調用命令行的東西,是在活動TestSettings指定安裝腳本:

enter image description here

相關問題