简体   繁体   English

无法并行运行测试(Selenium grid + NUnit)

[英]Cannot run tests in parallel (Selenium grid + NUnit)

Im using NUnit 3.5 in combination with a selenium grid (selenium-server-standalone-2.53.0.jar) with two nodes (one node is on the same machine as the hub).我将 NUnit 3.5 与具有两个节点的硒网格(selenium-server-standalone-2.53.0.jar)结合使用(一个节点与集线器在同一台机器上)。

Executing tests sequentially on the grid works well.在网格上按顺序执行测试效果很好。 Executing multiple sequential test suites at the same time (ie executing two separate test projects, the hub distributes the tests to one hub each) also works well.同时执行多个顺序测试套件(即执行两个单独的测试项目,集线器将测试分别分配到一个集线器)也能很好地工作。

What I cannot get to work is running multiple test classes from the same project in parallel.我无法开始工作的是并行运行同一项目中的多个测试类。 What i'm trying to do is execute some of the test classes (containing multiple tests) in parallel to each other.我想要做的是并行执行一些测试类(包含多个测试)。 Basically, my two (or more) test classes look like this:基本上,我的两个(或更多)测试类如下所示:

[Parallelizable(ParallelScope.Fixtures)]
public class Search {

    [Test]
    public void TestSomething() {
        //Test here
    }

    [Test]
    public void TestSomethingElse() {
        //Test something else here
    }

Instead of tests executed in parallel, I get really weird results.我得到了非常奇怪的结果,而不是并行执行的测试。 Although they seem to execute in parallel, the tests/sessions seems to get mixed up.尽管它们似乎并行执行,但测试/会话似乎混淆了。 For example, the log output (Console.WriteLine) from one test will be shown in the output for another test.例如,一个测试的日志输出 (Console.WriteLine) 将显示在另一个测试的输出中。 So a test that passes could have log output saying it has failed (since we output some logging on failed tests).因此,通过的测试可能会有日志输出说它失败了(因为我们在失败的测试上输出了一些日志)。

Hub config: Same as default, but using port 8887集线器配置:与默认相同,但使用端口 8887

Node config:节点配置:

{
  "capabilities": [
    {
      "browserName": "firefox",
      "maxInstances": 5,
      "cleanSession": true 
    },
    {
      "browserName": "chrome",
      "maxInstances": 5
    },
    {
      "browserName": "internet explorer",
      "maxInstances": 1
    }
  ],
  "configuration": {
    "_comment" : "Configuration for Node",
    "cleanUpCycle": 2000,
    "timeout": 10000,
    "port": 5555,
    "host": "sto-selenium02",
    "register": true,
    "hubPort": 8887,
    "maxSessions": 3
  }
}

What am I missing here?我在这里缺少什么? How can the sessions/tests be mixed up, or is it something else at play here?会话/测试如何混淆,或者这里是否有其他东西在起作用? All help appreciated!所有帮助表示赞赏!

I've come along the same problem and it turned out that the WebDriver instances was coded to be static variables.我遇到了同样的问题,结果发现 WebDriver 实例被编码为静态变量。 When that was removed, the tests could be run in parallel.当它被删除时,测试可以并行运行。

Hope that helps!希望有帮助!

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

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