我的 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
属性(property)连同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 中的并行测试执行感兴趣,请发表评论或其他任何内容。
简而言之,我发现了一个启用并行执行的拉取请求,它甚至被合并到了一个分支中。但是它还没有合并到 master 中。所以我现在看到的唯一出路是编写我自己的自定义 BaseSpecRunner
关于spring - 并行运行 Spock 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41897862/