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?

猜你喜欢

转载自www.cnblogs.com/niaomingjian/p/9047516.html
今日推荐