简体   繁体   English

Selenium GRID 2 + NUnit 3选项可并行运行测试

[英]Selenium GRID 2 + NUnit 3 options to run tests in parallel

I decided to switch from current solution (using modified NUnit by our team some years ago NDistribUnit which run tests on VirtualMachines and then gather results on hub server) to Selenium Grid 2. 我决定从当前解决方案(几年前使用我们团队使用经过修改的NUnit NDistribUnit在VirtualMachines上运行测试,然后在集线器服务器上收集结果)切换到Selenium Grid 2。

Option with ParallelizableAttribute was tried. 尝试了具有ParallelizableAttribute的选项。 Unfortunately I noticed that IWebDriver was stored in Global variable (puhh). 不幸的是,我注意到IWebDriver存储在全局变量(puhh)中。 This caused tests to start several browser instances, but tests used single IWebDriver -> tests execution happened in single browser -> tests were run under single process, but with several 'worker' threads. 这导致测试启动多个浏览器实例,但是测试使用单个IWebDriver->测试在单个浏览器中执行->测试在单个进程下运行,但是具有多个“工作者”线程。 It was tried using 2 VMs as 'nodes' and local PC as Hub. 尝试使用2个VM作为“节点”,并使用本地PC作为集线器。

I know best solution is to change invalid idea to store driver in global variable, but it'll take too much time: there are 3k+ heavy UI tests to be updated; 我知道最好的解决方案是更改无效的主意以将驱动程序存储在全局变量中,但是这将花费太多时间:有3k +繁重的UI测试需要更新; many static methods expected to have driver as global var to be updated also. 许多静态方法都希望将驱动程序作为全局变量进行更新。

As well NUnit 3.0 provides Option to run several assemblies in parallel. NUnit 3.0还提供了Option以并行运行多个程序集。 To run several test projects it's good, but currently we have 1 assembly per one application. 要运行多个测试项目很好,但是目前每个应用程序有1个程序集。 It would be nice to run tests for one application (one assembly) in parallel. 并行运行一个应用程序(一个程序集)的测试会很好。

Is there other ways to use GRID + NUnit 3 here to make it work? 还有其他使用GRID + NUnit 3的方法来使其工作吗?


Finally, existed solution were refactored: now each test during execution has own driver. 最终,重构了现有的解决方案:现在,执行期间的每个测试都有自己的驱动程序。 Due to this change a lot of code was re-written (it appears that too much methods expected to have IwebDriver as global variable) 由于此更改,许多代码被重写(似乎有太多方法希望将IwebDriver用作全局变量)

Actually, there are 2 options to do that: 实际上,有两种选择可以做到这一点:

  1. Refactoring - it's done for one test project. 重构-完成一个测试项目。 Along with removing static variables (initial refactoring purpose) other code was changed as well. 除了删除静态变量(初始重构目的)以外,还更改了其他代码。 A great minus - significant effort was required. 很大的缺点-需要付出很大的努力。
  2. Using TeamCity agents for parallel run. 使用TeamCity代理进行并行运行。 I forgot to mention finally tests are being executed on TeamCity, but by single agent. 我忘了提一下,最终测试是在TeamCity上执行的,但是由单个代理执行。 For left 'old' tests (where Driver instance was stored in static variable) several TC agents were configured to run only several classes from tests solution. 对于左“旧”测试(驱动程序实例存储在静态变量中),几个TC代理配置为仅运行测试解决方案中的几个类。 This option is very 'fast' and doesn't require big code changes. 此选项非常“快速”,不需要大的代码更改。

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

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