0
我已经实现了我自己的测试亚军与一个重写的runChild()方法:如何从测试运行器获取JUnit测试结果?
public class MyTestRunner extends BlockJUnit4ClassRunner {
// ...
@Override
protected void runChild(FrameworkMethod method, RunNotifier notifier) {
if (method.getAnnotation(Ignore.class) != null) {
return;
}
// Do some global pre-action
// ...
// Runs the passed test case
super.runChild(method, notifier);
// Do some global post-action depending on the success of the test case
// ...
}
// ...
}
我重写此方法,因为我需要之前做一些全球前和后操作/测试用例执行之后。后续行动将取决于测试用例执行的失败/成功。我如何检索执行结果?
你知道[Rules](https://github.com/junit-team/junit/wiki/Rules)吗? –
规则必须在测试类/方法级别上实现,但我不希望我的测试知道任何有关后置动作 – user1613270