JUnit 4.9.x及更高版本
从JUnit 4.9开始,TestWatchman不推荐使用TestWatcher该类,而推荐使用该类:
@Rule
public TestRule watcher = new TestWatcher() {
protected void starting(Description description) {
System.out.println("Starting test: " + description.getMethodName());
}
};
注意:必须声明包含类public。
JUnit 4.7.x-4.8.x
以下方法将打印类中所有测试的方法名称:
@Rule
public MethodRule watchman = new TestWatchman() {
public void starting(FrameworkMethod method) {
System.out.println("Starting test: " + method.getName());
}
};
最后
以上就是故意啤酒最近收集整理的关于junit 测试似有方法_获取JUnit 4中当前正在执行的测试的名称的全部内容,更多相关junit内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复