在Webtest中找不到依赖请求 [英] Cannot find a dependent request in webtest

查看:117
本文介绍了在Webtest中找不到依赖请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已在VS2015中使用Webtest记录器记录了一个测试.当我重新运行测试时,在某一时刻它因.css文件的相关GET请求而失败. Webtest结果中的url显示如下内容: https://mycompany/blah/ Style%20Guides/Global_CSS.css 该错误是简单的404错误. 现在,我转到主请求并搜索此特定的从属请求,以便可以将其Parse_Dependent_Request选项设置为False或将Extected_Http_Status_Code设置为404,这对我来说总是可行的.但是我无法在主请求或任何其他请求下找到此特定的依赖请求.

I have recorded a test with my webtest recorder in VS2015. When I am rerunning the test,at one point it fails at a dependent GET request of a .css file. The url in the webtest result shows something like this https://mycompany/blah/Style%20Guides/Global_CSS.css The error is a simple 404 error. Now I go to the main request and search for this particular dependent request so that I can set its Parse_Dependent_Request option as False or set the Extected_Http_Status_Code as 404, which ever works is fine for me. But I am not able to find this particular dependent request under the main or any other request.

我试图将所有从属请求的所有Parse_Dependent_Request选项更改为false并了解哪一个实际发送了Get请求,但没有一个起作用.我从webtest生成了代码,并从字面上进行了页面搜索,徒劳.如何获得请求?

I have tried to change all the Parse_Dependent_Request option of all the dependent requests to false and understand which one actually sends the Get request, but none of them worked.I did a generate code from the webtest and literally did a page search but in vain.Do how do I get the request?

推荐答案

在网络测试中,许多相关请求(DR)都不明确.当主请求的parse dependent requeststrue时,Visual Studio将处理该主请求的HTML响应以查找DR,并将它们添加到DR列表中.也可以解析任何HTML的DR响应,并将其DR添加到列表中.

Many dependent requests (DRs) are not explicit in the web test. When parse dependent requests of the main request is true, Visual Studio processes the HTML response of that main request to find the DRs and they are added to the list of DRs. Any DR responses that are HTML may also be parsed and their DRs added to the list.

处理丢失或有问题的DR的一种技术是运行可修改DR列表的插件.下面的代码基于"Visual Studio性能测试快速参考指南" (版本3.6)的第189页上的WebTestDependentFilter. com/"rel =" nofollow noreferrer> Codeplex . Codeplex文档还有许多其他有关Web和负载测试的良好信息.

One technique to handle missing or problematic DRs is to run a plugin that modifies the list of DRs. The code below is based on the WebTestDependentFilter on page 189 of the "Visual Studio Performance Testing Quick Reference Guide" (Version 3.6) available from Codeplex. The Codeplex document has lots of other good information about web and load testing.

public class WebTestDependentFilter : WebTestPlugin
{
    public string FilterDependentRequestsThatStartWith { get; set; }
    public string FilterDependentRequestsThatEndWith { get; set; }
    public override void PostRequest(object sender, PostRequestEventArgs e)
    {
        WebTestRequestCollection depsToRemove = new WebTestRequestCollection();
        // Note, you can't modify the collection inside a foreach, hence the second collection
        // requests to remove.
        foreach (WebTestRequest r in e.Request.DependentRequests)
        {
            if (!string.IsNullOrEmpty(FilterDependentRequestsThatStartWith))
            {
                if (r.Url.StartsWith(FilterDependentRequestsThatStartWith))
                {
                    depsToRemove.Add(r);
                }
            }
            else if (!string.IsNullOrEmpty(FilterDependentRequestsThatEndWith))
            {
                if (r.Url.EndsWith(FilterDependentRequestsThatEndWith))
                {
                    depsToRemove.Add(r);
                }
            }
        }
        foreach (WebTestRequest r in depsToRemove)
        {
            e.WebTest.AddCommentToResult(string.Format("Removing dependent: {0}", r.Url));
            e.Request.DependentRequests.Remove(r);
        }
    }
}

可以轻松修改以上代码中的搜索条件,以(例如)检查URL的中间部分.

The search criteria in the above code can easily be modified to (for example) check the middle parts of the URL.

另一种变化是将某些DR的预期响应代码设置为其他值.与删除失败的DR相比,这可能会进行更准确的性能测试,因为仍然需要服务器来处理请求并返回响应.

Another variation is to set the expected response code of some DRs to other values. This might make a more accurate performance test than deleting the failing DRs as the server is still required to handle the request and return a response.

这篇关于在Webtest中找不到依赖请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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