简体   繁体   中英

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).

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. 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

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. When that was removed, the tests could be run in parallel.

Hope that helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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