在 Maven 构建中并行运行 junit 测试? [英] Running junit tests in parallel in a Maven build?

查看:33
本文介绍了在 Maven 构建中并行运行 junit 测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 JUnit 4.4 和 Maven,并且我有大量长时间运行的集成测试.

I'm using JUnit 4.4 and Maven and I have a large number of long-running integration tests.

当谈到并行化测试套件时,有一些解决方案允许我在单个测试类中并行运行每个测试方法.但所有这些都要求我以一种或另一种方式更改测试.

When it comes to parallelizing test suites there are a few solutions that allow me to run each test method in a single test-class in parallel. But all of these require that I change the tests in one way or another.

我真的认为在 X 个线程中并行运行 X 个不同的测试类会是一个更简洁的解决方案.我有数百个测试,所以我并不真正关心线程化单个测试类.

I really think it would be a much cleaner solution to run X different test classes in X threads in parallel. I have hundreds of tests so I don't really care about threading individual test-classes.

有没有办法做到这一点?

Is there any way to do this?

推荐答案

从 junit 4.7 开始,现在可以在不使用 TestNG 的情况下并行运行测试.实际上,从 4.6 开始就可以了,但是在 4.7 中进行了许多修复,使其成为一个可行的选择.您还可以使用 spring 运行并行测试,您可以阅读有关 这里

From junit 4.7 it's now possible to run tests in parallel without using TestNG. Actually it has been possible since 4.6, but there are a number of fixes being made in 4.7 that will make it a viable option. You may also run parallel tests with spring, which you can read about here

这篇关于在 Maven 构建中并行运行 junit 测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆