從Junit4.7開始能夠並行運行測試。html
必須設置parallel 參數,能夠改變threadCount或useUnlimitedThreads屬性。apache
測試中指定了parallel,項目使用的是 JUnit 4.7+的話,就會用到concurrent JUnit provider,它利用了JUnit JUnitCore test runner。併發
(對於能夠有高併發的測試頗有用)eclipse
Surefire 2.7以前,不須要額外的依賴。maven
Surefire 2.16以前,引入了threadCountSuites, threadCountClasses 和threadCountMethods。另外,parallelTestsTimeoutInSeconds 和parallelTestsTimeoutForcedInSeconds用來在超時後關閉並行執行。ide
☆ 方法級別的並行,測試類級別的並行高併發
Links:測試
1. Running Tests in Parallel - mavenui
2. Run JUnit4-Tests parallel in Eclipsehtm