Visual Studio 2015 Load Testing - Where is Webtest.AddCommentToResult exposed?

637 views Asked by At

I am trying to add instrumentation to my load test code as well as perform validation of my web responses in a validation rule. I was hoping I could achieve both of these needs using the Webtest.AddCommentToResult method found here:

However I cannot seem to find where these comments I add get exposed, both in the load test results when I view them in the analyzer as they run and finish, or in the SQL controller after the fact. How are these comments exposed and can I access them?

My custom validation rule:

 public class MyCustomValidationRule : ValidationRule
 {
    static int i = 1;

    public override void Validate(object sender, ValidationEventArgs e)
    {
        e.WebTest.AddCommentToResult("Test comment number " + i++.ToString());
    }
 }
1

There are 1 answers

4
AdrianHHH On BEST ANSWER

The Web Performance Test Results Viewer has the log of running the ".webtest". During (and after) the execution of a ".webtest", the top panel of the viewer shows the requests as they are (or have been) executed, together with columns for status and timing etc. The Log includes any comments explicit in the ".webtest" and it includes any from the AddCommentToResult call.

The bottom panel of the viewer has tabs for "Web browser", "Request", "Response", "Context" and "Details".

Please be aware that comments added by an AddCommentToResult call are written to the viewer's log before the line showing the request.

Normally, when web tests are run as part of a load test, only the logs of tests that fail are saved. Logs of successful tests are discarded. This can be altered via the properties of the run settings used for the test. Properties Maximum test logs (default = 200) and Save log on test failure (default true) have obvious meanings. Property Save log frequency for completed tests (default = 0 = Zero) controls how many logs are kept for successful tests. If all the test cases in the test pass then the default settings mean that no logs are kept and hence none of the comments written by an AddCommentToResult call will be retained. If the original question is intended to ask "how can we save some data from each test case that is executed?" then my best answer is to write some data yourself to a log file (perhaps using a StreamWriter).

Some versions of Visual Studio have not shown a comment from AddCommentToResult when it is called from the PostWebTest plugin and where that ".webtest" is being run as part of a load test. See here.