簡體   English   中英

使用 maven 確保測試花費的時間超過指定的超時時間

[英]Tests taking more time than specified timeout using maven surefire

我在 pom.xml 中設置了所有超時屬性。

    <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-surefire-plugin</artifactId>
       <version>3.0.0-M3</version>
       <configuration>              
          <forkCount>${surefire.forkNumber}</forkCount>
          <reuseForks>false</reuseForks>
          <argLine>-Xmx2G -XX:MaxMetaspaceSize=2G </argLine>
          <parallel>methods</parallel>
          <threadCount>${surefire.threadCount}</threadCount>
          <forkedProcessTimeoutInSeconds>40s</forkedProcessTimeoutInSeconds>
          <forkedProcessExitTimeoutInSeconds>40s</forkedProcessExitTimeoutInSeconds>
          <parallelTestsTimeoutInSeconds>30s</parallelTestsTimeoutInSeconds>
          <parallelTestsTimeoutForcedInSeconds>30s</parallelTestsTimeoutForcedInSeconds> 
       </configuration>
    </plugin>

但我仍然看到一些測試花費的時間超過 40 秒(一個測試甚至需要 17 分鍾)。 可能的原因是什么? 如何使用surefire強制30秒超時?

文檔指定您必須啟用選項

平行

您必須設置<parallelTestTimeoutForcedInSeconds>5</parallelTestTimeoutForcedInSeconds>以強制當前運行超時。

如果您正在使用

並行測試超時InSeconds

只有排隊的線程將停止執行

參考: http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM