JUnitCore停止 [英] JUnitCore Stopping
本文介绍了JUnitCore停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想停止/销毁以
JUnitCore.run(Request.aClass(ClassToRun));
类似于RunNotifier上的pleaseStop()
.
Like pleaseStop()
on the RunNotifier.
有什么想法吗?
http://junit.sourceforge.net/javadoc/org/junit/runner/package-summary.html
推荐答案
我想提供另一个简单的解决方案来停止JUnitCore:
I want to provide another simple solution to stop a JUnitCore:
JUnitCore jUnitCore = new JUnitCore();
Field field = JUnitCore.class.getDeclaredField("fNotifier");
field.setAccessible(true);
RunNotifier runNotifier = (RunNotifier) field.get(jUnitCore);
runNotifier.pleaseStop();
感谢Matthew Farwell,他将我的想法转化为代码.
Credits to Matthew Farwell who transfered my idea into code.
这篇关于JUnitCore停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文