Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Spock tests in parallel

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!

like image 662
Dmitry Senkovich Avatar asked Jan 27 '17 15:01

Dmitry Senkovich


Video Answer


2 Answers

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

like image 53
Dmitry Senkovich Avatar answered Sep 28 '22 00:09

Dmitry Senkovich


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

like image 39
Suresh Naik Avatar answered Sep 28 '22 00:09

Suresh Naik