其他分享
首页 > 其他分享> > spring – 并行运行Spock测试

spring – 并行运行Spock测试

作者:互联网

我的E2E测试运行得非常缓慢(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属性以及parallel或forkCount,但对我来说没有任何作用.另外,我试图在maven-failsafe-plugin依赖项中强制执行以下依赖项:

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

提前致谢!

解决方法:

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

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

如果您对Spock中的并行测试执行感兴趣,请发表评论或其他任何内容.

简而言之,我发现了一个启用并行执行的pull请求,它甚至被合并到一个分支中.但是它尚未合并为主人.因此,我现在唯一的出路就是编写自己的自定义BaseSpecRunner

标签:spring,integration-testing,spock,e2e-testing,maven-failsafe-plugin
来源: https://codeday.me/bug/20190608/1197922.html