简体   繁体   English

如何并行运行NUnit(Selenium Grid)测试?

[英]How can I run NUnit(Selenium Grid) tests in parallel?

My current project uses NUnit for unit tests and to drive UATs written with Selenium. 我当前的项目使用NUnit进行单元测试并驱动用Selenium编写的UAT。 Developers normally run tests using ReSharper's test runner in VS.Net 2003 and our build box kicks them off via NAnt. 开发人员通常在VS.Net 2003中使用ReSharper的测试运行器运行测试,我们的构建盒通过NAnt将其启动。

We would like to run the UAT tests in parallel so that we can take advantage of Selenium Grid/RCs so that they will be able to run much faster. 我们希望并行运行UAT测试,以便我们可以利用Selenium Grid / RC,以便它们能够更快地运行。

Does anyone have any thoughts on how this might be achieved? 有没有人对如何实现这一点有任何想法? and/or best practices for testing Selenium tests against multiple browsers environments without writing duplicate tests automatically? 和/或针对多个浏览器环境测试Selenium测试而不自动编写重复测试的最佳实践?

Thank you. 谢谢。

There hasn't been a lot of work on this subject. 关于这个问题还没有很多工作。 I didn't find anything really relevent. 我没有找到任何真正相关的东西。

However, your point is well taken. 但是,你的观点很好。 Most machines nowadays have more cores and less powerful cores compared to powerful one core cpu. 与强大的一个核心CPU相比,现在大多数机器拥有更多内核和更低功能的内核。

So I did find something on a Microsoft blog. 所以我确实在微软博客上找到了一些东西。 The technology is called PUnit and is made especially for testing multi-threaded environment. 该技术称为PUnit,专门用于测试多线程环境。

It's as close as possible to what you requested that I could find :) 它尽可能接近您的要求,我可以找到:)

You can visit it the appropriate blog post right there: http://blogs.microsoft.co.il/blogs/eyal/archive/2008/07/09/punit-parallel-unit-testing-in-making.aspx 你可以在那里访问相应的博客文章: http//blogs.microsoft.co.il/blogs/eyal/archive/2008/07/09/punit-parallel-unit-testing-in-making.aspx

Update: Link is not valid anymore. 更新:链接不再有效。 The project on CodePlex has been removed. CodePlex上的项目已被删除。

Update2: This is on the roadmap for NUnit 2.5. Update2:这是NUnit 2.5的路线图。 Reference 参考

I struggled with both these problems myself. 我自己也在努力解决这两个问题。 In the end I developed a custom Nunit test runner that is capable of running multiple tests in parrallel. 最后,我开发了一个定制的Nunit测试运行器,能够以并行方式运行多个测试。 This combined with the Taumuon.Rakija extension for nunit allowed the tests to be dynmaically created depending on which browser you want the test to run on. 这与nunit的Taumuon.Rakija扩展相结合,允许根据您希望测试运行的浏览器来动态创建测试。

I'm now in a position where I can launch my test suite against as many browser types on as many operating systems as I wish in parrallel. 我现在处于这样一个位置:我可以在多个操作系统上针对尽可能多的浏览器类型启动我的测试套件。

Unfortunately there doesn't seem to be a good solution to these problems already so you'll probably have to solve them yourself for your particular environment. 不幸的是,这些问题似乎没有一个好的解决方案,所以你可能必须自己为你的特定环境解决它们。

NUnit version 3 will support running tests in parallel, this works good with a Selenium Grid: NUnit版本3将支持并行运行测试,这适用于Selenium Grid:

Adding the attribute to a class: [Parallelizable(ParallelScope.Self)] will run your tests in parallel with other test classes. 将属性添加到类: [Parallelizable(ParallelScope.Self)]将与其他测试类并行运行测试。

• ParallelScope.None indicates that the test may not be run in parallel with other tests. •ParallelScope.None表示测试可能无法与其他测试并行运行。

• ParallelScope.Self indicates that the test itself may be run in parallel with other tests. •ParallelScope.Self表示测试本身可以与其他测试并行运行。

• ParallelScope.Children indicates that the descendants of the test may be run in parallel with respect to one another. •ParallelScope.Children指示测试的后代可以相对于彼此并行运行。

• ParallelScope.Fixtures indicates that fixtures may be run in parallel with one another. •ParallelScope.Fixtures表示灯具可以彼此并行运行。

NUnit Framework-Parallel-Test-Execution NUnit框架 - 并行 - 测试 - 执行

Igor Brejc has a blog post about running tests in parallel using MbUnit. Igor Brejc有一篇关于使用MbUnit并行运行测试的博客文章。

However he does say "Once we integrate Selenium into acceptance testing", so it looks like he was just experimenting, I can't find any other posts so I don't know if he has successfully run Selenium tests in parallel. 然而他确实说“一旦我们将Selenium整合到验收测试中”,所以看起来他只是在尝试,我找不到任何其他帖子,所以我不知道他是否已成功并行运行Selenium测试。

http://igorbrejc.net/development/continuous-integration/gallio-running-tests-in-parallel http://igorbrejc.net/development/continuous-integration/gallio-running-tests-in-parallel

You can use the Task Parallel Library and the DynamicObject class to achieve parallelization of the same test on multiple browsers. 您可以使用Task Parallel Library和DynamicObject类在多个浏览器上实现相同测试的并行化。 See my article Running Selenium In Parallel with any .NET Unit Testing Tool for details. 有关详细信息,请参阅我的文章与任何.NET单元测试工具并行运行Selenium

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM