Junit 并行执行测试

从Junit4.7开始能够并行运行测试。html

必须设置parallel 参数,能够改变threadCountuseUnlimitedThreads属性。apache

测试中指定了parallel,项目使用的是 JUnit 4.7+的话,就会用到concurrent JUnit provider,它利用了JUnit JUnitCore test runner。并发

(对于能够有高并发的测试颇有用)eclipse

Surefire 2.7以前,不须要额外的依赖。maven

Surefire 2.16以前,引入了threadCountSuitesthreadCountClasses 和threadCountMethods。另外,parallelTestsTimeoutInSeconds 和parallelTestsTimeoutForcedInSeconds用来在超时后关闭并行执行。ide

 

方法级别的并行,测试类级别的并行高并发

 

Links:测试

1. Running Tests in Parallel - mavenui

2. Run JUnit4-Tests parallel in Eclipsehtm

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

4. JUnit 中是以测试方法为一个独立的生命周期

相关文章
相关标签/搜索