BogdanSorlea
BogdanSorlea

Reputation: 472

Integration Tests on Geb / Spock + Selenium Grid do not run in parallel

I have the following set-up: an integration tests project which has a suite of tests written in Groovy/Geb + Spock, which are running perfectly both using Selenium WebDriver and Selenium Grid (RemoteWebDriver).

The problem is that no matter how much I try to tweak the "system", I can't get the tests to run in parallel (i.e. although I have 3 slaves [nodes] registered to the hub, only one of the slaves actually receives the requests). I've enforced maxSession=1 to the Selenium nodes and tried different combinations of parallel=classes|methods, threadCount and fork settings in failsafe plugin configuration (pom.xml file).

I have the feeling that the problem lies somewhere between the maven configuration and selenium grid, probably in relation to Geb/Spock config.

Does any of you have any insight on this issue?

PS: someone suggested that running tests in parallel using Geb / Spock is not possible - because for some reason ?Geb? locks the JUnitRunner (not sure what this means).

Upvotes: 2

Views: 1941

Answers (3)

Karthikeyan
Karthikeyan

Reputation: 2724

You can run it for sure, The point is you have to put them (your tests) in threads. Here is the link.

Upvotes: 0

Nikhil
Nikhil

Reputation: 43

Add following configuration to your build.gradle file:

tasks.withType(Test) {
        maxParallelForks = 3 // here three forks shall open in parallel
        forkEvery = 1
        include '**/*TestName*.class'   // name of your test class
}

Upvotes: 2

Thomas Hirsch
Thomas Hirsch

Reputation: 2308

There are test frameworks, TestNG for example, that support parallel testing on the method level out of the box. Spock, as an example to the contrary, does not support it.

But you do not have to have multithreading implemented by your test framework to make this work.
You can use your build tool to run test classes in parallel, both Maven and Gradle support this.

If you are using Maven, this documentation page and examples might help you: https://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html Specifically have a look at "Forked Test Execution".

Upvotes: 1

Related Questions