在并行运行Spock测试

6

我的端到端测试运行速度很慢(25分钟),因为它们调用了一堆服务并等待数据库中填充一些数据。我想并发运行它。我正在使用以下maven-failsafe-plugin设置:

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

我的测试看起来像这样(如果需要可以提供更多信息):

@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
}

我试图使用threadCount属性与parallelforkCount一起使用,但对我来说都没有起作用。此外,我尝试在maven-failsafe-plugin的依赖项中强制使用以下依赖项:

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

提前感谢您!

2个回答

8

我在GitHub上遇到了以下问题:

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

如果你也对Spock中的并行测试执行感兴趣,可以留下评论或其他内容。

简而言之,我发现了一个启用并行执行的拉取请求,它甚至已经合并到了其中一个分支中。然而,它还没有合并到主分支中。所以目前我看到的唯一出路是编写自己的定制 BaseSpecRunner


从我在这个PR中看到的,它涉及到在同一规范中并行执行测试。基于类的并行化应该可以正常工作。 - jihor
@jihor 在 Gradle 中。 - Dmitry Senkovich

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接