多线程 - MS 测试 - 数据驱动测试
背景
我在“mstest”中编写了一个测试套件,其中有一个 XML 模板。
该测试使用我的数据库中的数据填充此模板,并将其发布到 Web 服务。当 Web 服务回复响应时,输入的 XML 数据将与其响应中从服务接收的 XML 数据进行比较,并将条目记录在文本文件中。
基本上,这个测试有一个入口点函数(它是唯一具有测试方法属性的函数),然后驱动测试中的所有其他函数
问题 问题
是当测试花费太长时间时。每个实例发布到 Web 服务并获取回复几乎需要 2 分钟,而且我有 100 个此类数据实例,因此至少需要大约 200 分钟才能完成。
我的老板告诉我在这个测试中研究多线程,从而希望减少时间。
我想指出的另一件事是,我正在使用 DataSource 属性来遍历不同的输入 xml 实例,类似于 本文。不同之处在于,我使用数据库中的视图来运行数据源属性,而不是 CSV 文件。
任何如何进行多线程测试并维护线程安全的想法将不胜感激。 提前致谢
Background
I have written a test suite in "mstest" which has a template XML.
The test populates this template with data from my database and posts it to a web service. When the web service replies with a response, input XML data is compared with the XML data received from the service in its response, and entries are logged in a text file.
Basically this test has one entry point function (it's the only function with the test method attribute) which then drives all the other functions in the test
The problem
The problem is that when the test takes too long. Posting to the web service and getting back a reply takes almost 2 mins for each instance and I have 100 such data instances, so it would take about 200 mins at a minimum to complete.
My Boss told me to look into multi-threading this test thus hopefully reducing time.
One more thing i would like to point out is that I am going through different input xml instances using the DataSource attribute similar to what is mentioned in this article. The difference is that I am using a view from my DB to run the datasource attribute rather than a CSV file.
Any ideas how to multi thread this test and maintain thread safety will be greatly appreciated.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您能否详细说明如何执行对“mstest”的调用?
如果您手动执行测试执行,那么您可以非常轻松地添加多线程支持并节省大量宝贵的时间,正如您老板所考虑的那样:)
我附上了此 MSDN 概述链接,其中还涵盖了线程安全的基础知识:
http://msdn.microsoft.com/en-us/library/ms173178.aspx
如果您使用 IDE/测试应用程序的内置选项,则您可能会受限于它必须提供的功能。
等待您的答复。
Can you please elaborate on how you execute the calls to "mstest"?
If you are manually executing test execution, then you can add multi-thread support very easily and save a lot of precious time, as your boss has in mind :)
I attached this MSDN overview link which also covers the basics for thread safety:
http://msdn.microsoft.com/en-us/library/ms173178.aspx
If you're using a built-in option of the IDE/test application, that you may be limited to the functionality it has to offer.
Waiting for your answer.
TPL 对我有用,只需确保每个变量都是本地的
TPL works for me, just had to ensure each and every variable was local