我有大約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中的進度條只是填充到最後,而且沒有任何事情發生,一切都是綠色的,很棒。
有人可以幫助我嗎?