创建 Visual Studio Web 测试以上传具有随机文件名的文件
我(经过相当多的工作)进行了一个 Web 测试,该测试将使用测试中包含的文件和标识该文件的 DeploymentItem 将文件上传到我的 SharePoint 文档库,以便可以在文件上传 post 参数中使用它。
效果很好,现在暂时忽略 SharePoint 因素,图像我想将 Web 测试作为负载测试的一部分运行。 这意味着文件上传测试需要运行相当多的次数。 如果我一直将相同的文件上传到相同的文件名,那就不太好了。
我想要做的是使用相同的文件数据在目标上创建一个随机文件。 例如,我希望上传的文件具有文件名“image1”+ Guid.NewGuid.ToString() +“.jpg”。
除了在光盘上创建一个具有该名称的新文件并添加部署项或每次查找该文件的内容之外,我不知道如何执行此操作。 这尤其是一个问题,因为 Web 测试将通过测试代理在一台机器上运行,而我实际上无法在该机器上创建那么多代码。
最坏的情况是我会在上传文件后删除该文件。
关于我如何做到这一点有什么想法吗?
I have (after quite a bit of work) a web test that will upload a file to my SharePoint document library using a file that is included in the test and DeploymentItem that identifies that file so it can be used in the file upload post parameter.
That works great, now ignoring the SharePoint factor for a moment, image that I want to run the webtest as part of a loadtest. That means that the file upload test needs to be run a fair amount of times. That is not so great if I am upload the same file to the same filename all the time.
What I want to do is to create a random file at the target, using the same file data. e.g. I want the file that is uploaded to have the filename "image1" + Guid.NewGuid.ToString() + ".jpg".
Aside from creating a new file on the disc with that name and adding a Deployment item or something to locate the file each time, I am at a loss as how to do this. This is especially a problem as the web test will be run via a test agent on a machine that I will not really be able to create that much code on.
Worst case scenario I will go with deleteing the file after uploading it.
Any ideas on how I can do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
给定一个场景,其中文件 image1.jpg 被设置为部署项并被复制到构建目标,以下代码将创建一个可在
使用该文件后以所需的方式上传的文件
given a scenarion where the file image1.jpg is being set as the deployment item and is being copied to the build target, the following code creates a file available for upload in the manner required
after the file has been used