【发布时间】:2014-04-03 09:00:11
【问题描述】:
我有一个主要的测试类 (A) 和另一个从它扩展的 (B)。
A 有一个 @RunWith(SpringJUnit4ClassRunner.class) 注释来初始化它。
我需要在 B 上使用@RunWith(JUnitParamsRunner.class) 注释。
但我似乎无法同时做到这两点。有没有办法在没有@RunWith 注释的情况下使用参数化测试套件?
另一种解决方案是使用
testContextManager = new TestContextManager(AbstractInvoiceCreationModuleTest.class);
testContextManager.prepareTestInstance(this);
但是我不能在@BeforeClass 方法中写这个,因为它是静态的并且不允许使用它。我不希望在@Before 方法中编写上述代码,因为该类将在每个测试方法之前被初始化。并且很多测试类都从 A 扩展而来。
可以做什么?
【问题讨论】:
标签: java spring unit-testing junit