Visual Studio 2015负载测试-哪里公开了Webtest.AddCommentToResult? [英] Visual Studio 2015 Load Testing - Where is Webtest.AddCommentToResult exposed?

查看:96
本文介绍了Visual Studio 2015负载测试-哪里公开了Webtest.AddCommentToResult?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将工具添加到我的负载测试代码中,并在验证规则中对我的Web响应进行验证.我希望可以使用

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:

但是,我似乎找不到这些添加的注释,无论是在负载测试结果中(在运行和结束时在分析器中查看它们,还是事后在SQL控制器中)时,它们都是暴露的.这些评论如何显示?我可以访问它们吗?

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?

我的自定义验证规则:

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

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

推荐答案

Web性能测试结果查看器具有运行".webtest"的日志.在执行".webtest"期间(及之后),查看器的顶部面板显示正在执行(或已执行)的请求,以及状态和时间等列.日志中包含在".webtest"中明确显示的所有注释. ".webtest",其中包括AddCommentToResult调用中的任何内容.

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.

查看器的底部面板具有"Web浏览器",请求",响应",上下文"和详细信息"的选项卡.

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

请注意,由AddCommentToResult调用添加的注释将在显示请求的行之前写入查看者的日志中.

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

通常,当Web测试作为负载测试的一部分运行时,仅保存失败的测试日志.成功测试的日志将被丢弃.可以通过用于测试的运行设置的属性来更改此设置.属性Maximum test logs(默认= 200)和Save log on test failure(默认true)具有明显的含义.属性Save log frequency for completed tests(默认= 0 =零)控制为成功测试保留的日志数量.如果测试中的所有测试用例都通过,则默认设置意味着不保留任何日志,因此将不保留任何由AddCommentToResult调用编写的注释.如果原始问题旨在询问我们如何从每个执行的测试案例中保存一些数据?" ,那么最好的答案是自己将一些数据写入日志文件(也许使用StreamWriter).

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).

PostWebTest插件中调用Visual Studio的某些版本并在负载测试的一部分中运行".webtest"时,没有显示AddCommentToResult的注释.请参阅此处.

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.

这篇关于Visual Studio 2015负载测试-哪里公开了Webtest.AddCommentToResult?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆