[英]jUnit: How to filter tests found in multiple suites
When jUnit runs a test suite containing multiple "sub suites", is it possible to filter tests found in different suites as to make them run only once ? 当jUnit运行包含多个“子套件”的测试套件时,是否可以过滤在不同套件中找到的测试以使其只能运行一次 ? I'm working on a project with many database integration tests so it's desirable run these only once as to make it quicker.
我正在一个具有许多数据库集成测试的项目中,因此最好只运行一次以使其更快。
Consider this "main suite": 考虑一下这个“主套件”:
@RunWith(Suite.class)
@SuiteClasses
({
ModuleASuite.class,
ModuleBSuite.class,
// More suites...
})
public class MainSuite
{}
And these "sub suites": 这些“子套件”:
@RunWith(Suite.class)
@SuiteClasses
({
TestA1.class,
TestA2.class,
//... More tests only related to ModuleA
SomeTestUsedByManyModules.class
})
public class ModuleASuite
{}
@RunWith(Suite.class)
@SuiteClasses
({
TestB1.class,
TestB2.class,
//... More tests only related to ModuleB
SomeTestUsedByManyModules.class
})
public class ModuleBSuite
{}
Currently when running MainSuite
using jUnit 4.4 (using Eclipse or Ant) it runs SomeTestUsedByManyModules
twice. 目前运行的时候
MainSuite
使用JUnit 4.4(使用Eclipse的Ant或)运行SomeTestUsedByManyModules
两次。 How can I make it run only once? 如何使其只能运行一次? I thought of making my own Runner but maybe there's an easer solution for this?
我曾想过要制作自己的Runner,但也许有一个更简便的解决方案?
I don't know how to do it with @RunWith(Suite), but what about a different approach? 我不知道如何使用@RunWith(Suite)进行操作,但是另一种方法呢? ClassPathSuite lets you provide test name patterns to avoid the need to list them all out manually.
ClassPathSuite允许您提供测试名称模式,从而无需手动列出所有名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.