Running Spock tests in parallel
Asked Answered
J

2

6

My E2E tests are running pretty slowly (25 minutes) as they call a bunch of services and wait for some data to be populated in the database. I want to run it concurrently. I'm using the following maven-failsafe-plugin setup:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>${plugin.failsave.version}</version>
    <executions>
        <execution>
            <id>run-integration-tests</id>
            <phase>integration-test</phase>
            <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>

And my test looks something like this (more information can be provided if it is needed):

@Stepwise
@DataJpaTest
@ContextConfiguration(classes = SomeControllerITConfig)
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
class SomeControllerIT extends Specification {
    // some variables definition

    def "test1":
        // some test

    def "test2":
        // some test

    // some more tests
}

I tried to use threadCount property along with parallel or forkCount but nothing works for me. Also I tried to force the following dependency in the maven-failsafe-plugin dependencies:

<dependency>
      <groupId>org.apache.maven.surefire</groupId>
      <artifactId>surefire-junit47</artifactId>
      <version>2.16</version>
</dependency>

Thanks in advance!

Joab answered 27/1, 2017 at 15:48 Comment(0)
J
8

I ended up with the following issue on GitHub:

https://github.com/spockframework/spock/issues/691

Comment or whatever if you're also interested in parallel test execution in Spock.

In short, I've found a pull request with enabling parallel execution and it is even merged into one of the branches. However it is not merged into master yet. So the only way out I see for now is to write my own custom BaseSpecRunner

Joab answered 31/1, 2017 at 9:7 Comment(2)
From what is see in this PR, it relates to parallelizing execution of tests in the same Spec. Class-based parallelization should work fine as it is.Harlan
@Harlan in Gradle onlyJoab
A
1

Looks like Spock team added support for parallel execution:

http://spockframework.org/spock/docs/2.0-M4/parallel_execution.html#parallel-execution

requires groovy: >3.0.6

Additory answered 5/11, 2020 at 20:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.