@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(); }
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 testRunStarted(Description description) { debugOrInfo(c("Test run started", INFO)); }
@Override public void testStarted(Description description) { recordStartTime(description); logger.pushCurrentTestClassName(description.getClassName()); debugOrInfo("Test " + settings.buildInfoName(description) + " started"); capture(); }
@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()); } }); }
void logTo(RichLogger logger) { logger.warn("Test assumption in test "+ansiName+" failed: "+ansiMsg + durationSuffix()); } });
void logTo(RichLogger logger) { logger.debug("Test "+ansiName+" finished" + durationSuffix()); } });
void logTo(RichLogger logger) { logger.error("Test "+ansiName+" failed: "+ansiMsg + durationSuffix(), error); } });
void error(String s, Throwable t) { error(s); if(t != null && (settings.logAssert || !(t instanceof AssertionError))) logStackTrace(t); }
/** * @return <tt>true</tt> if at least one (any) parent category match a child, otherwise <tt>false</tt>. * If empty <tt>parentCategories</tt>, returns <tt>false</tt>. */ private boolean matchesAnyParentCategories(Set<Class<?>> childCategories, Set<Class<?>> parentCategories) { for (Class<?> parentCategory : parentCategories) { if (hasAssignableTo(childCategories, parentCategory)) { return true; } } return false; }
protected CategoryFilter(boolean matchAnyIncludes, Set<Class<?>> includes, boolean matchAnyExcludes, Set<Class<?>> excludes) { includedAny = matchAnyIncludes; excludedAny = matchAnyExcludes; included = copyAndRefine(includes); excluded = copyAndRefine(excludes); }
/** * @see #toString() */ @Override public String describe() { return toString(); }
InfoEvent(Description desc, Status status) { super(settings.buildInfoName(desc), null, status, elapsedTime(desc), null); } }
private void capture() { if(settings.quiet && capture == null) capture = OutputCapture.start(); }
@Override public Task[] tasks(TaskDef[] taskDefs) { int length = taskDefs.length; Task[] tasks = new Task[length]; for (int i = 0; i < length; i++) { TaskDef taskDef = taskDefs[i]; tasks[i] = createTask(taskDef); } return tasks; }
@Override public void testIgnored(Description desc) { postIfFirst(new InfoEvent(desc, Status.Skipped) { void logTo(RichLogger logger) { logger.info("Test "+ansiName+" ignored"); } }); }
@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); } }); }
/** * @return <tt>false</tt> if at least one parent category does not match children, otherwise <tt>true</tt>. * If empty <tt>parentCategories</tt>, returns <tt>true</tt>. */ private boolean matchesAllParentCategories(Set<Class<?>> childCategories, Set<Class<?>> parentCategories) { for (Class<?> parentCategory : parentCategories) { if (!hasAssignableTo(childCategories, parentCategory)) { return false; } } return true; }