我有大约8 终端到终端的测试类,扩展我抽象 SpringContextLoadingTest类,它看起来像这样:摇篮正在执行测试非常慢,因为它增加了很多测试套件
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public abstract class SpringContextLoadingTest extends AbstractTestNGSpringContextTests {
}
我有@SpringBootApplication注释的主应用程序类。因为我使用TestNG,我在一个组中有一些类(“通道A”),而另一些中有一些(“通道B”)。
我的gradle做任务运行过程中出现不同的群体:
task runChannelA(type: Test) {
forkEvery = 1
useTestNG() {
includeGroups "channel A"
}
}
没有“forEvery = 1”,运行过程中出现超过1次测试时,有繁忙的港口的问题。
由于下面这个简单的配置,我收到来自gradle这个任务执行更详细的输出:
tasks.withType(Test) {
testLogging.showStandardStreams = true
}
没有它,它会显得测试执行后一样,应用程序挂起2分钟,在关闭EntityManagerFactory,但是这个标志揭示了Gradle拿起它没有被要求的测试。对于每个测试,无论它在哪个组中,gradle正在记录:
Gradle Test Executor 22 STANDARD_OUT
2016-12-21 17:10:00.115 INFO --- [ Test worker] .b.t.c.SpringBootTestContextBootstrapper : Neither @ContextConfiguration nor @ContextHierarchy found for test class [mypackage.OtherTest], using SpringBootContextLoader
2016-12-21 17:10:00.141 INFO --- [ Test worker] o.s.t.c.support.AbstractContextLoader : Could not detect default resource locations for test class [mypackage.OtherTest]: no resource found for suffixes {-context.xml, Context.groovy}.
2016-12-21 17:10:00.143 INFO --- [ Test worker] t.c.s.AnnotationConfigContextLoaderUtils : Could not detect default configuration classes for test class [mypackage.OtherTest]: DbCongestionExploratoryTest does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
2016-12-21 17:10:00.455 INFO --- [ Test worker] .b.t.c.SpringBootTestContextBootstrapper : Found @SpringBootConfiguration mypackage.Application for test class mypackage.OtherTest
2016-12-21 17:10:00.466 INFO --- [ Test worker] .b.t.c.SpringBootTestContextBootstrapper : Using TestExecutionListeners: [or[email protected]9404cc4, org.springframework.test[email protected]46876feb, org.springframewor[email protected]dd46df5, org.springfra[email protected]49e2c374]
而且它需要很多时间,因为我有很多其他测试。在IntelliJ中可以看到我想要执行的测试已经通过后发生这种情况。例如,我在25秒后看到测试已经通过,但是因为它正在执行在我的项目中以这种方式设置的所有其他测试所做的任何尝试,runChannelA需要3分钟以上。有趣的是,我可以在这个奇怪的行为中停止这个过程,而IntelliJ中的进度条只是填充到最后,而且没有任何事情发生,一切都是绿色的,很棒。
有人可以帮助我吗?