@Override public void testAssumptionFailure(final Failure failure) { uncapture(true); postIfFirst(new ErrorEvent(failure, Status.Skipped) { void logTo(RichLogger logger) { logger.warn("Test assumption in test "+ansiName+" failed: "+ansiMsg + durationSuffix()); } }); }
@Override public void testStarted(Description description) { recordStartTime(description); logger.pushCurrentTestClassName(description.getClassName()); debugOrInfo("Test " + settings.buildInfoName(description) + " started"); capture(); }
new RunSettings(!nocolor, decodeScalaNames, quiet, verbose, logAssert, ignoreRunners, logExceptionClass); RichLogger logger = new RichLogger(loggers, settings, testClassName); EventDispatcher ed = new EventDispatcher(logger, eventHandler, settings, fingerprint); JUnitCore ju = new JUnitCore(); ju.addListener(ed); catch(Exception ex) { ed.testExecutionFailed(testClassName, ex); }
@Override public void testRunStarted(Description description) { debugOrInfo(c("Test run started", INFO)); }
@Override public void testIgnored(Description desc) { postIfFirst(new InfoEvent(desc, Status.Skipped) { void logTo(RichLogger logger) { logger.info("Test "+ansiName+" ignored"); } }); }
@Override public boolean shouldRun(Description d) { String displayName = d.getDisplayName(); // We get asked both if we should run the class/suite, as well as the individual tests // So let the suite always run, so we can evaluate the individual test cases if(displayName.indexOf('(') == -1) return true; String testName = displayName.substring(0, displayName.indexOf('(')); // JUnit calls this multiple times per test and we don't want to print a new "test ignored" // message each time if(ignored.contains(testName)) return false; for(String p : testPatterns) if(Pattern.matches(p, testName)) return true; ignored.add(testName); ed.testIgnored(d); return false; } }
void testExecutionFailed(String testName, Throwable err) { post(new Event(Ansi.c(testName, Ansi.ERRMSG), settings.buildErrorMessage(err), Status.Error, 0l, err) { void logTo(RichLogger logger) { logger.error("Execution of test "+ansiName+" failed: "+ansiMsg, error); } }); }
@Override public void testRunFinished(Result result) { debugOrInfo(c("Test run finished: ", INFO)+ c(result.getFailureCount()+" failed", result.getFailureCount() > 0 ? ERRCOUNT : INFO)+ c(", ", INFO)+ c(result.getIgnoreCount()+" ignored", result.getIgnoreCount() > 0 ? IGNCOUNT : INFO)+ c(", "+result.getRunCount()+" total, "+(result.getRunTime()/1000.0)+"s", INFO)); }
@Override public void testFailure(final Failure failure) { uncapture(true); postIfFirst(new ErrorEvent(failure, Status.Failure) { void logTo(RichLogger logger) { logger.error("Test "+ansiName+" failed: "+ansiMsg + durationSuffix(), error); } }); }
@Override public void testFinished(Description desc) { uncapture(false); postIfFirst(new InfoEvent(desc, Status.Success) { void logTo(RichLogger logger) { logger.debug("Test "+ansiName+" finished" + durationSuffix()); } }); logger.popCurrentTestClassName(); }