Junit 並行執行測試


從Junit4.7開始可以並行運行測試。

必須設置parallel 參數,可以改變threadCountuseUnlimitedThreads屬性。

測試中指定了parallel,項目使用的是 JUnit 4.7+的話,就會用到concurrent JUnit provider,它利用了JUnit JUnitCore test runner。

(對於可以有高並發的測試很有用)

Surefire 2.7之前,不需要額外的依賴。

Surefire 2.16之前,引入了threadCountSuitesthreadCountClasses 和threadCountMethods。另外,parallelTestsTimeoutInSeconds 和parallelTestsTimeoutForcedInSeconds用來在超時后關閉並行執行。

 

方法級別的並行,測試類級別的並行

 

Links:

1. Running Tests in Parallel - maven

2. Run JUnit4-Tests parallel in Eclipse

3. Running junit tests in parallel in a Maven build?

4. JUnit 中是以測試方法為一個獨立的生命周期

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM