在套件级别并行运行 JUnit 测试?
我有一堆在 JUnit 测试套件中组织的测试。这些测试大量利用 Selenium 来测试 Web 应用程序。因此,对于 selenium 来说,这些测试的运行时间自然是相当长的。由于测试数据库中存在一些重叠,套件中的测试类无法并行运行,因此我想并行运行套件。
JUnit ParallelComputer 只能并行执行类或方法级别的测试,JUnit 是否有任何标准方法可以通过套件执行此操作?
如果我只是将套件类传递给 junit 运行程序并将计算机配置为在类级别上并行化,它会选择测试类本身,而不是套件。
br 坦率
I have a bunch of tests that are organized in JUnit test suites. These tests are greatly utilizing selenium to test a web application. So, naturaly for selenium, the runtime of these tests is quite long. Since the test classes in the suites can not run parallel due some overlaps in the test database, i would like to run the suites parallel.
The JUnit ParallelComputer can only execute tests on class or method level in parallel, are there any standard ways for JUnit to do that with suites?
If i just pass suite classes to the junit runner and configure the computer to parallelize on class level, it picks the test classes itself, not the suites.
br
Frank
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一些对我有用的代码。这不是我写的。如果您使用
@RunWith(ConcurrentSuite.class)
而不是@RunWith(Suite.class)
它应该可以工作。还需要一个注释,如下所示。并且注释如下。
Here is some code that worked for me. I did not write this. If you use
@RunWith(ConcurrentSuite.class)
instead of@RunWith(Suite.class)
it should work. There is an annotation that is also needed which is found below.And the annotation is as follows.
由于 Suite 是用来注释 Class 的,所以以 JUnitCore.runClasses(ParallelComputer.classes(), cls) 的方式运行 Suite 注释的类。
cls
是 Suite 注解的类。Since Suite is used to annotate a Class, so run the Suite-annotated class in
JUnitCore.runClasses(ParallelComputer.classes(), cls)
way.cls
are Suite-annotated classes.