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

删除回忆录丶 提交于 2020-01-05 05:43:06

问题


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:


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.



来源:https://stackoverflow.com/questions/41233906/visual-studio-2015-load-testing-where-is-webtest-addcommenttoresult-exposed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!