從Junit4.7開始可以並行運行測試。
必須設置parallel 參數,可以改變threadCount或useUnlimitedThreads屬性。
測試中指定了parallel,項目使用的是 JUnit 4.7+的話,就會用到concurrent JUnit provider,它利用了JUnit JUnitCore test runner。
(對於可以有高並發的測試很有用)
Surefire 2.7之前,不需要額外的依賴。
Surefire 2.16之前,引入了threadCountSuites, threadCountClasses 和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?
