开发者

Display time for webtest plugin in playback UI window

I have written a Visual Stud开发者_StackOverflow中文版io (2008) Webtest plugin, and need to display the time it takes to run in the playback ui window.

I've tried:

e.WebTest.BeginTransaction("B2BValidate");

// then call my plugin

e.WebTest.EndTransaction("B2BValidate");

This indeed adds a "B2BValidate" transaction to the playback window, but the "Total Time" column displays as 0.000 sec. What am I missing?

-Matt


Transactions in Visual Studio expect to contain a request - they simply don't work directly inline in code like that without a request in between.

You'll have to use something like http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx to start and stop a timer and then use the AddCommentToResult() method of the WebTest to show the elapsed time in the webtest results viewer.

Another option is to put your webtest in a loadtest and then refer to the performance counters:

  • % Time in LoadTestPlugin
  • % Time in Rules
  • % Time in WebTest code

although of course that only gives proportions rather than precise timing data.


There is a TransactionTimer class which needs to be instantiated and the request scope for the timer defined.

       public class DynamicTransactionTimer : WebTestRequestPlugin
 {
 public override void PreRequest(object sender, PreRequestEventArgs e)
 {
     TransactionTimer t = new TransactionTimer();
     t.Name = "trx3";
     t.Items.Add(e.Request);
     e.WebTest.BeginTransaction("trx3"); 
 }

     public override void PostRequest(object sender, PostRequestEventArgs e)
     {
         e.WebTest.EndTransaction("trx3");
     }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜