Refine search
private void testAborted(RunNotifier notifier, Description description, Throwable e) { notifier.fireTestStarted(description); notifier.fireTestFailure(new Failure(description, e)); notifier.fireTestFinished(description); }
public void run() { if (testMethod.isIgnored()) { notifier.fireTestIgnored(description); return; } notifier.fireTestStarted(description); try { long timeout = testMethod.getTimeout(); if (timeout > 0) { runWithTimeout(timeout); } else { runTest(); } } finally { notifier.fireTestFinished(description); } }
public RunNotifier getNotifier(final TestResult result, final JUnit4TestAdapter adapter) { RunNotifier notifier = new RunNotifier(); notifier.addListener(new RunListener() { @Override public void testFailure(Failure failure) throws Exception { result.addError(asTest(failure.getDescription()), failure.getException()); } @Override public void testFinished(Description description) throws Exception { result.endTest(asTest(description)); } @Override public void testStarted(Description description) throws Exception { result.startTest(asTest(description)); } }); return notifier; }
@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); } }
private void testJVMBackendFrameworkMethod(final FrameworkMethod aFrameworkMethod, final RunNotifier aRunNotifier) { final Description theDescription = Description.createTestDescription(testClass.getJavaClass(), aFrameworkMethod.getName() + " JVM Target"); aRunNotifier.fireTestStarted(theDescription); try { // Simply invoke using reflection final Object theInstance = testClass.getJavaClass().getDeclaredConstructor().newInstance(); final Method theMethod = aFrameworkMethod.getMethod(); theMethod.invoke(theInstance); aRunNotifier.fireTestFinished(theDescription); } catch (final Exception e) { aRunNotifier.fireTestFailure(new Failure(theDescription, e)); } }
@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); } }
protected void spincastTestError(String testName, Throwable exception) { this.logger.error("Test error", exception); Description description = Description.createTestDescription(getTestClass().getJavaClass(), testName); setIgnoreRemainingTests(); getRunNotifier().fireTestStarted(description); getRunNotifier().fireTestFailure(new Failure(description, exception)); getRunNotifier().fireTestFinished(description); }
public class MyRunner extends BlockJUnit4ClassRunner { public MyRunner(Class<?> klass) throws InitializationError { super(klass); } @Override protected void runChild(final FrameworkMethod method, RunNotifier notifier) { Description description= describeChild(method); if (method.getAnnotation(Ignore.class) != null) { notifier.fireTestIgnored(description); } else { if (description.getAnnotation(Deprecated.class) != null) { System.out.println("name=" + description.getMethodName() + " annotations=" + description.getAnnotations()); } runLeaf(methodBlock(method), description, notifier); } } }
protected void addFailure(Throwable e) { notifier.fireTestFailure(new Failure(description, e)); } }
@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); }
public void validateUnusedStubs(Class<?> testClass, RunNotifier notifier) { Collection<Invocation> unused = new UnusedStubbingsFinder().getUnusedStubbingsByLocation(mocks); if (unused.isEmpty()) { return; //whoa!!! All stubbings were used! } //Oups, there are unused stubbings Description unnecessaryStubbings = Description.createTestDescription(testClass, "unnecessary Mockito stubbings"); notifier.fireTestFailure(new Failure(unnecessaryStubbings, Reporter.formatUnncessaryStubbingException(testClass, unused))); }
@Override protected void runChild(final FrameworkMethod method, RunNotifier notifier) { Description description = describeChild(method); if (method.getAnnotation(Ignore.class) != null) { notifier.fireTestIgnored(description); } else { runLeaf(methodBlock(method), description, notifier); } }
@Override public void fireTestAssumptionFailed(Failure failure) { Description description = failure.getDescription(); String methodName = description.getMethodName(); Throwable throwable = failure.getException(); if (methodName == null) { LoggingUtil.INSTANCE.error("Test class assumption failed", throwable); } else { LoggingUtil.INSTANCE.error("Test method assumption failed", throwable); } runNotifier.fireTestAssumptionFailed(failure); }
@Override public void runChild(FrameworkMethod method, RunNotifier notifier) { MinVersion methodCondition = method.getAnnotation(MinVersion.class); MinVersion classCondition = this.getTestClass().getJavaClass().getAnnotation(MinVersion.class); String versionStr = VersionInfo.getVersion(); int version = VersionUtil.encodeVersion(versionStr); if ( (methodCondition == null || version >= VersionUtil.encodeVersion(methodCondition.value())) && (classCondition == null || version >= VersionUtil.encodeVersion(classCondition.value()))) { super.runChild(method, notifier); } else { notifier.fireTestIgnored(describeChild(method)); } }
instance = testClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { notifier.fireTestFailure(new Failure(description, e)); return false; method.invoke(instance); } catch (InvocationTargetException e) { notifier.fireTestFailure(new Failure(description, e.getTargetException())); } catch (IllegalAccessException e) { notifier.fireTestFailure(new Failure(description, e)); notifier.fireTestFailure(new Failure(description, e)); return false; notifier.fireTestAssumptionFailed(new Failure(description, new AssertionError("Expected exception was not thrown"))); return false; method.invoke(instance); } catch (InvocationTargetException e) { notifier.fireTestFailure(new Failure(description, e.getTargetException())); } catch (IllegalAccessException e) { notifier.fireTestFailure(new Failure(description, e));
void reportAsIgnored(RunNotifier notifier, GroupEvaluator ge, TestCandidate c) { if (c.method.getAnnotation(Ignore.class) != null) { notifier.fireTestIgnored(c.description); return; } String ignoreReason = ge.getIgnoreReason(c.method, suiteClass); if (ignoreReason != null) { notifier.fireTestStarted(c.description); notifier.fireTestAssumptionFailed(new Failure(c.description, new AssumptionViolatedException(ignoreReason))); notifier.fireTestFinished(c.description); } }
/** * Check whether the test is enabled in the current execution environment. * <p>This prevents classes with a non-matching {@code @IfProfileValue} * annotation from running altogether, even skipping the execution of * {@code prepareTestInstance()} methods in {@code TestExecutionListeners}. * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Class) * @see org.springframework.test.annotation.IfProfileValue * @see org.springframework.test.context.TestExecutionListener */ @Override public void run(RunNotifier notifier) { if (!ProfileValueUtils.isTestEnabledInThisEnvironment(getTestClass().getJavaClass())) { notifier.fireTestIgnored(getDescription()); return; } super.run(notifier); }
@Override public void afterFeature(FeatureInfo feature) { if (feature.isParameterized()) { if (iterationCount == 0 && !errorSinceLastReset) notifier.fireTestFailure(new Failure(feature.getDescription(), new SpockExecutionException("Data provider has no data"))); } masterListener.afterFeature(feature); if (!feature.isReportIterations()) notifier.fireTestFinished(feature.getDescription()); currentFeature = null; }
@Override public void run(RunNotifier notifier) { notifier.fireTestAssumptionFailed(new Failure(description, exception)); } }
/** * Fails the {@link #introspection} test unless we managed to share a compiler. */ private void verifyCompilerShared(RunNotifier notifier, int numChildren, int numCompilations) { System.out.println(String.format( "Merged %d tests into %d compiler passes", numChildren, numCompilations)); int numFilteredChildren = superDescription.get().getChildren().size(); if (numFilteredChildren == numChildren) { if (numChildren == numCompilations) { notifier.fireTestFailure(new Failure( introspection, new AssertionError(MERGE_FAILURE_MESSAGE))); } } }