junit源码之Runner
Runner
定义了执行用例的执行器方法。
public abstract class Runner implements Describable { /* 获取描述 */ public abstract Description getDescription(); /** 运行测试用例*/ public abstract void run(RunNotifier notifier); /***/ public int testCount() { return getDescription().testCount(); } }
ParentRunner
@Override public void run(final RunNotifier notifier) { EachTestNotifier testNotifier = new EachTestNotifier(notifier, getDescription()); testNotifier.fireTestSuiteStarted(); try { Statement statement = classBlock(notifier); statement.evaluate(); } catch (AssumptionViolatedException e) { testNotifier.addFailedAssumption(e); } catch (StoppedByUserException e) { throw e; } catch (Throwable e) { testNotifier.addFailure(e); } finally { testNotifier.fireTestSuiteFinished(); } }
BlockJUnit4ClassRunner