Refine search
private String stringify(Description description) { return description.getClassName() + "." + description.getMethodName() + "()"; } }
@Override public Statement apply(Statement base, Description description) { if (description.isEmpty()) { return base; } else { final Class<?> testClass = description.getTestClass(); final FrameworkMethod frameworkMethod; try { final Method method = testClass.getMethod(description.getMethodName()); frameworkMethod = new FrameworkMethod(method); } catch (NoSuchMethodException e) { throw new IllegalStateException(e); } return delegate.apply(base, frameworkMethod, testInstance); } } }
public JUnit4SpockMethod(Description description) { super((Method)null); this.declaringClass = description.getTestClass(); this.description = description.getDisplayName(); }
private static Description parentDescription(Description description) { Class<?> testClass= description.getTestClass(); return testClass == null ? null : Description.createSuiteDescription(testClass); }
private static boolean canHaveCategorizedChildren(Description description) { for (Description each : description.getChildren()) { if (each.getTestClass() == null) { return false; } } return true; } }
@Override public void evaluate() throws Throwable { Throwable caughtThrowable = null; for (int i = 0; i < retryCount; i++) { try { base.evaluate(); return; } catch (Throwable t) { caughtThrowable = t; System.err.println(description.getDisplayName() + ": run " + (i + 1) + " failed"); int n = sleep; if (backoff && i != 0) { n = n * (2 << i); } Thread.sleep(n); } } System.err.println(description.getDisplayName() + ": giving up after " + retryCount + " failures"); throw caughtThrowable; } }
private void run(CloserRule closer, final Runnable runnable) throws Throwable { closer.apply( new Statement() { @Override public void evaluate() { runnable.run(); } }, Description.createTestDescription( CloserRuleTest.class.getCanonicalName(), "baseRunner", UUID.randomUUID() ) ).evaluate(); } }
@Override public void evaluate() throws Throwable { // If this is used as class rule then getMethodName() returns null, so use // getClassName() instead. String name = description.getMethodName() != null ? description.getMethodName() : description.getClassName(); workingDirectory = testDirectory.directory( name ); ensureDatabase( settings -> {} ); try { statement.evaluate(); } finally { shutdownDatabase(); } } };
@Override public void evaluate() throws Throwable { if (contextSelectorClass != null) { System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, contextSelectorClass.getName()); } // TODO Consider instead of the above: // LogManager.setFactory(new Log4jContextFactory(LoaderUtil.newInstanceOf(contextSelectorClass))); System.setProperty(SYS_PROP_KEY_CLASS_NAME, description.getClassName()); System.setProperty(SYS_PROP_KEY_DISPLAY_NAME, description.getDisplayName()); loggerContext = Configurator.initialize(description.getDisplayName(), description.getTestClass().getClassLoader(), configLocation); try { base.evaluate(); } finally { if (!Configurator.shutdown(loggerContext, shutdownTimeout, shutdownTimeUnit)) { StatusLogger.getLogger().error("Logger context {} did not shutdown completely after {} {}.", loggerContext.getName(), shutdownTimeout, shutdownTimeUnit); } loggerContext = null; contextSelectorClass = null; StatusLogger.getLogger().reset(); System.clearProperty(Constants.LOG4J_CONTEXT_SELECTOR); System.clearProperty(SYS_PROP_KEY_CLASS_NAME); System.clearProperty(SYS_PROP_KEY_DISPLAY_NAME); } } };
protected void evaluate(final Statement statement, final Description description) throws Throwable { if (isTest(description)) { Repeat repeat = description.getAnnotation(Repeat.class); for (int count = 0, repetitions = getRepetitions(repeat); count < repetitions; count++) { statement.evaluate(); } } }
@Override public void evaluate() throws Throwable { Long prevNotificationId = getCurrentNotificationId(); statement.evaluate(); Long currNotificationId = getCurrentNotificationId(); if(!testsToSkip.contains(description.getMethodName())){ doBackwardCompatibilityCheck(prevNotificationId,currNotificationId); } else { LOG.info("Skipping backward compatibility check, as requested, for test :" + description); } } };
@Override protected void starting(Description description) { System.out.println("\n[Test Case starting] " + description.getTestClass().getSimpleName() + "." + description.getMethodName() + "()\n"); }
@Override public void run(RunNotifier notifier) { Class<?> testClass = getTestClass().getJavaClass(); try { manager.beforeClass(stagedReactor, testClass); super.run(notifier); } // CHECKSTYLE:SKIP : catch all wanted catch (Throwable e) { // rethrowing the exception does not help, we have to use the notifier here Description description = Description.createSuiteDescription(testClass); notifier.fireTestFailure(new Failure(description, e)); } finally { manager.afterClass(stagedReactor, testClass); } }
@Override protected void starting(Description d) { name = d.getMethodName(); }
@Override public void fireTestFailure(Failure failure) { String className = failure.getDescription().getClassName(); String methodName = failure.getDescription().getMethodName(); if (methodName == null) { logger.error("Test Class {} Failed", className); } else { logger.error("Test Method '{}' Failed", methodName); } notifier.fireTestFailure(failure); }
@Override public void fireTestFailure(Failure failure) { Description description = failure.getDescription(); String methodName = description.getMethodName(); Throwable throwable = failure.getException(); if (methodName == null) { LoggingUtil.INSTANCE.error("Test method '{}' failed", methodName, throwable); } else { LoggingUtil.INSTANCE.error("Test method failed", throwable); } runNotifier.fireTestFailure(failure); }
@Override public void fireTestAssumptionFailed(Failure failure) { String className = failure.getDescription().getClassName(); String methodName = failure.getDescription().getMethodName(); if (methodName == null) { logger.error("Test Class {} Failed", className); } else { logger.error("Test Method '{}' Failed", methodName); } notifier.fireTestAssumptionFailed(failure); }
private void notifyTestFailed(final Description junitDescription, final Throwable cause) { if (junitRunNotifier != null && junitDescription != null) { log.debug(junitDescription.getDisplayName() + " notify running TestFailed"); log.debug(junitDescription.getDisplayName() + " notify TestFailed"); junitRunNotifier.fireTestFailure(new Failure(junitDescription, cause)); } }
@Override public void evaluate() { description = Description.createTestDescription(fClass, STEP + fTestMethod.getName()); fNotifier.fireTestStarted(description); try { fTestMethod.invokeExplosively(fTarget); } catch (Throwable e) { //NOSONAR fNotifier.fireTestFailure(new Failure(description, e)); } fNotifier.fireTestFinished(description); } }
@Override public Description getDescription() { Description description = Description.createSuiteDescription(classNames); for (Throwable each : causes) { description.addChild(describeCause()); } return description; }