下面列出了org.junit.internal.runners.model.EachTestNotifier#fireTestFinished ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void invokeTest(RunNotifier notifier, TestExecutorType type, FrameworkMethod method) {
if ((type == null) || TestExecutorType.LOCAL.equals(type)) {
runLeaf(methodBlock(method), describeChild(method), notifier);
} else {
EachTestNotifier eachNotifier = new EachTestNotifier(notifier, describeChild(method));
try {
eachNotifier.fireTestStarted();
execute(type, method.getMethod()).get();
} catch (Throwable e) {
log.error("Test " + method + " failed with exception ", e);
eachNotifier.addFailure(unwrap(e));
} finally {
eachNotifier.fireTestFinished();
}
}
}
@Override
public void runChild(final FrameworkMethod method, final RunNotifier notifier) {
final Description description = describeChild(method);
if (this.isIgnored(method)) {
notifier.fireTestIgnored(description);
} else {
final EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
eachNotifier.fireTestStarted();
boolean ignored = false;
try {
this.methodBlock(method).evaluate();
} catch (AssumptionViolatedException ave) {
eachNotifier.addFailedAssumption(ave);
} catch (Throwable e) {
if (validateForGraphComputer(e)) {
eachNotifier.fireTestIgnored();
logger.info(e.getMessage());
ignored = true;
} else
eachNotifier.addFailure(e);
} finally {
if (!ignored)
eachNotifier.fireTestFinished();
}
}
}
@Override
protected void runChild(FrameworkMethod method, RunNotifier notifier) {
Description description = describeChild(method);
if (method.getAnnotation(Ignore.class) != null) {
notifier.fireTestIgnored(description);
} else {
setLogContext(method);
EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
eachNotifier.fireTestStarted();
try {
runTestMethod(method, eachNotifier, config.getTimeoutRetries());
} finally {
eachNotifier.fireTestFinished();
clearLogContext();
}
}
}
@Override
protected void runChild(final FrameworkMethod method, RunNotifier notifier) {
Description description = describeChild(method);
if (method.getAnnotation(Ignore.class) != null) {
notifier.fireTestIgnored(description);
} else {
EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
eachNotifier.fireTestStarted();
try {
runTestMethod(method, eachNotifier);
} finally {
eachNotifier.fireTestFinished();
}
}
}
@Override
protected void runChild(final FrameworkMethod method, RunNotifier notifier) {
Description description = describeChild(method);
if (method.getAnnotation(Ignore.class) != null) {
notifier.fireTestIgnored(description);
} else {
EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
eachNotifier.fireTestStarted();
try {
runTestMethod(method, eachNotifier);
} finally {
eachNotifier.fireTestFinished();
}
}
}