使用JUnit3 TestCase

时间:2016-01-28 13:29:26

标签: java unit-testing junit junit4 junit3

首先让我解释一下测试设置,

我为这个非常大的项目工作,该项目有许多较小的模块。为了测试,我们以两种方式使用JUnit,

  • JUnit 4:使用@Test注释,我们使用派生自BlockJunit4ClassRunner的自定义测试运行器
  • JUnit 3:我们大量的测试是从XML文件动态创建的,基于junit.framework.TestCase。我们也有一个自定义测试运行器,它继承了org.junit.runners.AllTests。

对于一些跨领域的非功能性需求,我们已经实现了一些规则(org.junit.rules),我们通过使用@Rule注释测试类来使用这些规则。这适用于JUnit4但不适用于JUnit3。

有没有直接的方法来实现它而不做太多改变?

对于BlockJunit4ClassRunner,我们有FrameworkMethod,

@Override
protected void runChild(final FrameworkMethod method, RunNotifier     notifier) {  
...
}

但是在AllTests的情况下,我们没有,

@Override
public void run(RunNotifier notifier) {
...
...
}

0 个答案:

没有答案
相关问题