通过Microsoft WebTest上载文件 [英] Upload a file through a microsoft webtest

查看:88
本文介绍了通过Microsoft WebTest上载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.webtest,打算用来将文件上传到网站上进行负载测试.我正在使用Visual Studio中内置的Webtest框架,目的是从Azure中运行大规模测试.

我创建了一个新的网络测试并记录了步骤,包括文件上传.所有这些都记录正确,但是问题在于文件上载参数只是记录了文件名(而不是字节).这意味着测试需要有权访问将在运行期间上载的文件.

我还将文件添加到项目中并将其设置为内容.

问题是文件在运行期间没有被复制.我发现了一个博客文章 https://blogs.msdn.microsoft.com/edglas/2008/08/05/how-to-upload-a-file-in-a-web-test/回答了我的问题,但是visual studio ui发生了变化,该选项不再可用.

我不能使用绝对URL c:\ files \ filename.docx,因为我需要从azure运行它.

我也无法将文件发布到Internet上的某个地方,因为它必须是路径,而不是URL.

我已经在博客文章中发布了一个问题,但是它似乎并不十分活跃,并且对于从这里去哪里真的很茫然.

TIA, -Logan

解决方案

Ed Glass博客的最后一个屏幕截图中显示的部署"功能现在位于解决方案的.testsettings文件中. (博客显示一个带有"localtestrun.testrunco​​nfig"文件的窗口.)如果您有多个.testsettings文件,请确保正确文件的上下文菜单中已选中活动负载和Web测试设置".

.testsettings文件的部署部分中,选中启用部署",然后添加要在测试中使用的目录或文件.运行测试后,您应该发现项目已被复制到TestResults\{{name+date+time}}目录的子目录中,如博客中所述.

可以将

新的.testsettings文件添加到解决方案中,如下所示.从解决方案的上下文菜单(解决方案资源管理器中最顶层的项目)中,选择添加 => 新项目 => 测试设置(从添加新项"窗口的左侧),然后填写表格.也可以通过测试设置编辑器中的另存为"按钮来创建新文件,但这需要已打开文件.

在创建新的.testsettings文件时,我建议更改常规"部分中的名称"字段以匹配文件名.不这样做(在使用另存为"之后)使我感到困惑,因为两个或多个文件似乎具有相同的名称.通常,一个解决方案中最多包含三个.testsettings文件:开发测试时供本地使用的一个.另一个(通常称为"cloud"或"vsts")配置为使用VSTS进行云负载测试.与控制器和代理一起使用的第三个版本(通常称为代理"或远程").

I have a .webtest that I am intending to use to load test uploading a file to a website. I am using the webtest framework that is built into visual studio with the intention of running my larger scale tests from azure.

I created a new webtest and recorded the steps, including the file upload. This all recorded correctly, but the problem is that the File Upload Parameter was just recorded the filename (not the bytes). This means that the test needs to have access to the file that will be uploaded during running.

I also added the file to the project and set it to be content.

The problem is that the file isn't getting copied over during running. I found a blog post https://blogs.msdn.microsoft.com/edglas/2008/08/05/how-to-upload-a-file-in-a-web-test/ which appears to answer my question but the visual studio ui has changed and the option is no longer available.

I cannot use an absolute url c:\files\filename.docx because i need to run this from azure.

I also cannot post the file somewhere on the internet because it has to be a path, not a url.

I have posted a queston to the blog post, but it doesn't seem very active and am really at a lose for where to go from here.

TIA, -Logan

解决方案

The "Deployment" functionality shown in the last screenshot of Ed Glass's blog is now in the .testsettings files of the solution. (The blog shows a window with a "localtestrun.testrunconfig" file.) If you have more than one .testsettings file then ensure that the context menu of the correct file has the "Active load and web test settings" ticked.

In the deployment section of the .testsettings file, tick "Enable deployment" and add the directory or file(s) to be used in the tests. After running a test you should then find that the items have been copied into a subdirectory of the TestResults\{{name+date+time}} directory, as described in the blog.

New .testsettings files can be added to a solution as follows. From the context menu of the solution (the topmost item in Solution Explorer), select Add => New item => Test settings (from the left hand side of the "Add new item" window), then fill in the forms. New files can also be created via the "Save as" button in the test settings editor, but this requires a file to already be open.

When creating new .testsettings files I recommend changing the "Name" field in the "General" section to match the filename. Not doing so (after using "Save as") has left me confused because two or more files appear to have the same name. I normally have up to three .testsettings file in a solution: One for local use when developing tests. Another (often named "cloud" or "vsts") configured for cloud load testing with VSTS. The third version (often named "agent" or "remote") for use with controllers and agents.

这篇关于通过Microsoft WebTest上载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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