org.junit.runner.notification.RunNotifier Java Examples
The following examples show how to use
org.junit.runner.notification.RunNotifier.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OleasterRunner.java From oleaster with Apache License 2.0 | 6 votes |
@Override protected void runChild(Spec spec, RunNotifier notifier) { List<Spec> specs = spec.getSuite().getSpecs(); boolean suiteHasNoSpecs = specs.isEmpty(); boolean isFirstSpec = specs.indexOf(spec) == 0; boolean isLastSpec = specs.indexOf(spec) == specs.size() -1; if (suiteHasNoSpecs || isFirstSpec){ runBeforeCallbacks(spec); } if (spec.getBlock().isPresent()) { runBeforeEachCallbacks(spec); runLeaf(spec, describeChild(spec), notifier); runAfterEachCallbacks(spec); } else { notifier.fireTestIgnored(describeChild(spec)); } if (suiteHasNoSpecs || isLastSpec){ runAfterCallbacks(spec); } }
Example #2
Source File: ZeroCodePackageRunner.java From zerocode with Apache License 2.0 | 6 votes |
/** * Runs the test corresponding to {@code child}, which can be assumed to be * an element of the list returned by {@link ParentRunner#getChildren()}. * Subclasses are responsible for making sure that relevant test events are * reported through {@code notifier} * * @param child * @param notifier */ @Override protected void runChild(ScenarioSpec child, RunNotifier notifier) { final Description description = Description.createTestDescription(testClass, child.getScenarioName()); // ---------------------------------------------- // Notify that this single test has been started. // Supply the scenario/journey name // ---------------------------------------------- notifier.fireTestStarted(description); passed = zeroCodeMultiStepsScenarioRunner.runScenario(child, notifier, description); testRunCompleted = true; if (passed) { LOGGER.info(String.format("\nPackageRunner- **FINISHED executing all Steps for [%s] **.\nSteps were:%s", child.getScenarioName(), child.getSteps().stream().map(step -> step.getName()).collect(Collectors.toList()))); } notifier.fireTestFinished(description); }
Example #3
Source File: SmartAssert.java From codenjoy with GNU General Public License v3.0 | 6 votes |
@Override @SneakyThrows public void run(RunNotifier notifier) { System.out.println("running the tests from SmartAssert: " + test); Object testObject = test.newInstance(); for (Method method : test.getMethods()) { if (!method.isAnnotationPresent(Test.class)) continue; notifier.fireTestStarted(description(method)); method.invoke(testObject); checkResult(failures(test.getName())); notifier.fireTestFinished(description(method)); } }
Example #4
Source File: TestRunner.java From sis with Apache License 2.0 | 6 votes |
/** * Before to delegate to the {@linkplain BlockJUnit4ClassRunner#runChild default implementation}, * check if a dependency of the given method failed. In such case, the test will be ignored. * * @param method the test method to execute. * @param notifier the object to notify about test results. */ @Override protected void runChild(final FrameworkMethod method, final RunNotifier notifier) { if (skipAll) { notifier.fireTestIgnored(describeChild(method)); return; } if (methodDependencyFailures != null) { final DependsOnMethod assumptions = method.getAnnotation(DependsOnMethod.class); if (assumptions != null) { for (final String assumption : assumptions.value()) { if (methodDependencyFailures.contains(assumption)) { methodDependencyFailures.add(method.getName()); notifier.fireTestIgnored(describeChild(method)); return; } } } } super.runChild(method, notifier); }
Example #5
Source File: SystemTestRunner.java From pravega with Apache License 2.0 | 6 votes |
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(); } } }
Example #6
Source File: GremlinProcessRunner.java From tinkerpop with Apache License 2.0 | 6 votes |
@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(); } } }
Example #7
Source File: DefaultServer.java From quarkus-http with Apache License 2.0 | 6 votes |
private static void runInternal(final RunNotifier notifier) { if (openssl && OPENSSL_FAILURE != null) { throw new RuntimeException(OPENSSL_FAILURE); } if (first) { first = false; undertow = Undertow.builder() .setHandler(rootHandler) .addHttpListener(getHostPort(DEFAULT), getHostAddress(DEFAULT)) .build(); undertow.start(); notifier.addListener(new RunListener() { @Override public void testRunFinished(Result result) throws Exception { super.testRunFinished(result); undertow.stop(); clientGroup.shutdownGracefully(); } }); } }
Example #8
Source File: MyRunner.java From new-bull with MIT License | 6 votes |
@Override public void run(RunNotifier notifier) { System.out.println("running the tests from MyRunner. " + testClass); try { Object testObject = testClass.newInstance(); for (Method method : testClass.getMethods()) { if (method.isAnnotationPresent(Test.class)) { notifier.fireTestStarted(Description.EMPTY); method.invoke(testObject); notifier.fireTestFinished(Description.EMPTY); } } } catch (Exception e) { throw new RuntimeException(e); } }
Example #9
Source File: JavaScriptTestSuite.java From selenium with Apache License 2.0 | 6 votes |
@Override protected Statement classBlock(RunNotifier notifier) { final Statement suite = super.classBlock(notifier); return new Statement() { @Override public void evaluate() throws Throwable { TestEnvironment testEnvironment = null; try { testEnvironment = GlobalTestEnvironment.getOrCreate(InProcessTestEnvironment::new); suite.evaluate(); } finally { if (testEnvironment != null) { testEnvironment.stop(); } if (driverSupplier instanceof Closeable) { ((Closeable) driverSupplier).close(); } } } }; }
Example #10
Source File: ZeroCodeMultiLoadRunner.java From zerocode with Apache License 2.0 | 6 votes |
@Override protected void runChild(TestMapping[] childArrayElement, RunNotifier notifier) { notifier.fireTestStarted(testDescription); Arrays.stream(childArrayElement).forEach(thisChild -> { loadProcessor.addTest(thisChild.testClass(), thisChild.testMethod()); }); boolean hasFailed = loadProcessor.processMultiLoad(); if (hasFailed) { String failureMessage = testClass.getName() + " with load/stress test(s): " + testDescription + " have Failed"; LOGGER.error(failureMessage + ". See target/logs -or- junit granular failure report(csv) -or- fuzzy search and filter report(html) for details"); notifier.fireTestFailure(new Failure(testDescription, new RuntimeException(failureMessage))); } notifier.fireTestFinished(testDescription); }
Example #11
Source File: ZeroCodeMultiStepsScenarioRunnerImpl.java From zerocode with Apache License 2.0 | 6 votes |
private Boolean executeRetryWithSteps(RunNotifier notifier, Description description, ScenarioExecutionState scenarioExecutionState, ScenarioSpec scenario, Step thisStep) { thisStep = extFileProcessor.resolveExtJsonFile(thisStep); List<Step> thisSteps = extFileProcessor.createFromStepFile(thisStep, thisStep.getId()); if(null == thisSteps || thisSteps.isEmpty()) thisSteps.add(thisStep); Boolean wasExecSuccess = null; for(Step step : thisSteps) { wasExecSuccess = executeRetry(notifier, description, scenarioExecutionState, scenario, step); if (wasExecSuccess != null) { return wasExecSuccess; } } return null; }
Example #12
Source File: ConsoleSpammingMockitoJUnitRunner.java From astor with GNU General Public License v2.0 | 6 votes |
@Override public void run(RunNotifier notifier) { RunListener listener = new RunListener() { WarningsCollector warningsCollector; @Override public void testStarted(Description description) throws Exception { warningsCollector = new WarningsCollector(); } @Override public void testFailure(Failure failure) throws Exception { logger.log(warningsCollector.getWarnings()); } }; notifier.addListener(listener); runner.run(notifier); }
Example #13
Source File: QpidTestRunner.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Override protected void runChild(final FrameworkMethod method, final RunNotifier notifier) { BrokerSpecific brokerSpecific = method.getAnnotation(BrokerSpecific.class); if (brokerSpecific == null) { brokerSpecific = method.getDeclaringClass().getAnnotation(BrokerSpecific.class); } if (brokerSpecific != null && !brokerSpecific.kind().equalsIgnoreCase(_brokerAdmin.getKind())) { notifier.fireTestIgnored(describeChild(method)); } else { _brokerAdmin.beforeTestMethod(_testClass, method.getMethod()); try { super.runChild(method, notifier); } finally { _brokerAdmin.afterTestMethod(_testClass, method.getMethod()); } } }
Example #14
Source File: ComplianceRunner.java From jmespath-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void run(RunNotifier notifier) { for (JmesPathComplianceTest.ComplianceTest<T> complianceTest : getAllTests()) { Description testDescription = createDescription(complianceTest); notifier.fireTestStarted(testDescription); try { complianceTest.run(); } catch (AssertionError ae) { notifier.fireTestFailure(new Failure(testDescription, ae)); } catch (Exception e) { notifier.fireTestFailure(new Failure(testDescription, e)); } finally { notifier.fireTestFinished(testDescription); } } }
Example #15
Source File: DisablablePaxExam.java From components with Apache License 2.0 | 5 votes |
@Override public void run(final RunNotifier notifier) { if (!SystemUtils.JAVA_VERSION.startsWith("1.8.")) { notifier.fireTestAssumptionFailed(new Failure( Description.createSuiteDescription(clazz), new IllegalStateException("Java " + SystemUtils.JAVA_VERSION + " not yet supported"))); } else { super.run(notifier); } }
Example #16
Source File: AbstractMultiTestRunner.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void runEnabledTests(RunNotifier nested) { if (enabledTests.isEmpty()) { return; } Runner runner; try { runner = createExecutionRunner(); } catch (Throwable t) { runner = new CannotExecuteRunner(getDisplayName(), target, t); } try { if (!disabledTests.isEmpty()) { ((Filterable) runner).filter(new Filter() { @Override public boolean shouldRun(Description description) { return !disabledTests.contains(description); } @Override public String describe() { return "disabled tests"; } }); } } catch (NoTestsRemainException e) { return; } runner.run(nested); }
Example #17
Source File: ArchUnitRunner.java From ArchUnit with Apache License 2.0 | 5 votes |
@Override protected Statement classBlock(RunNotifier notifier) { final Statement statement = super.classBlock(notifier); return new Statement() { @Override public void evaluate() throws Throwable { try { statement.evaluate(); } finally { cache.clear(getTestClass().getJavaClass()); } } }; }
Example #18
Source File: ArkBootRunner.java From sofa-ark with Apache License 2.0 | 5 votes |
@Override public void run(RunNotifier notifier) { ClassLoader oldClassLoader = ClassLoaderUtils.pushContextClassLoader(DelegateArkContainer .getTestClassLoader()); try { notifier.addListener(JUnitExecutionListener.getRunListener()); runner.run(notifier); } finally { ClassLoaderUtils.popContextClassLoader(oldClassLoader); } }
Example #19
Source File: JavaScriptTestSuite.java From selenium with Apache License 2.0 | 5 votes |
@Override public void run(RunNotifier notifier) { notifier.fireTestStarted(description); try { testStatement.evaluate(); } catch (Throwable throwable) { Failure failure = new Failure(description, throwable); notifier.fireTestFailure(failure); } finally { notifier.fireTestFinished(description); } }
Example #20
Source File: TestHelper.java From havarunner with MIT License | 5 votes |
public static Failure runAndRecordFailure(HavaRunner havaRunner) { final AtomicReference<Failure> expectedFailure = new AtomicReference<>(); RunNotifier runNotifier = new RunNotifier() { @Override public void fireTestFailure(Failure failure) { expectedFailure.set(failure); } }; run(havaRunner, runNotifier); return expectedFailure.get(); }
Example #21
Source File: DisablablePaxExam.java From components with Apache License 2.0 | 5 votes |
@Override public void run(final RunNotifier notifier) { if (!SystemUtils.JAVA_VERSION.startsWith("1.8.")) { notifier.fireTestAssumptionFailed(new Failure( Description.createSuiteDescription(clazz), new IllegalStateException("Java " + SystemUtils.JAVA_VERSION + " not yet supported"))); } else { super.run(notifier); } }
Example #22
Source File: JustTestLahRunner.java From justtestlah with Apache License 2.0 | 5 votes |
@Override public void run(RunNotifier notifier) { if (properties.getProperty(CLOUD_PROVIDER, CLOUDPROVIDER_LOCAL).equals(CLOUDPROVIDER_AWS)) { awsRunner.run(notifier); } else { super.run(notifier); } }
Example #23
Source File: ZeroCodePackageRunner.java From zerocode with Apache License 2.0 | 5 votes |
@Override public void run(RunNotifier notifier) { ZeroCodeTestReportListener reportListener = new ZeroCodeTestReportListener(smartUtils.getMapper(), getInjectedReportGenerator()); notifier.addListener(reportListener); LOGGER.info("System property " + ZEROCODE_JUNIT + "=" + getProperty(ZEROCODE_JUNIT)); if (!CHARTS_AND_CSV.equals(getProperty(ZEROCODE_JUNIT))) { notifier.addListener(reportListener); } super.run(notifier); handleNoRunListenerReport(reportListener); }
Example #24
Source File: AbstractMultiTestRunner.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void run(RunNotifier notifier) { initDescription(); for (Execution execution : executions) { execution.run(notifier); } }
Example #25
Source File: DelegateRunnerWithTimeout.java From buck with Apache License 2.0 | 5 votes |
/** * Runs the tests for this runner, but wraps the specified {@code notifier} with a {@link * DelegateRunNotifier} that intercepts calls to the original {@code notifier}. The {@link * DelegateRunNotifier} is what enables us to impose our default timeout. */ @Override public void run(RunNotifier notifier) { DelegateRunNotifier wrapper = new DelegateRunNotifier(delegate, notifier, defaultTestTimeoutMillis); if (wrapper.hasJunitTimeout(getDescription())) { runWithoutBuckManagedTimeout(wrapper); } else { runWithBuckManagedTimeout(wrapper); } }
Example #26
Source File: AbstractMultiTestRunner.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void run(RunNotifier notifier) { initDescription(); for (Execution execution : executions) { execution.run(notifier); } }
Example #27
Source File: HeadlessTestRunner.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
@Override public void run(RunNotifier notifier) { if (GraphicsEnvironment.isHeadless()) { notifier.fireTestIgnored(getDescription()); return; } super.run(notifier); }
Example #28
Source File: RetryRunner.java From java-sdk with Apache License 2.0 | 5 votes |
@Override protected void runChild(final FrameworkMethod method, RunNotifier notifier) { Description description = describeChild(method); if (method.getAnnotation(Ignore.class) != null) { notifier.fireTestIgnored(description); } else { runTest(methodBlock(method), description, notifier); } }
Example #29
Source File: AbstractSuiteRunner.java From lambda-behave with MIT License | 5 votes |
protected void reportResults(final RunNotifier notifier, final SpecificationReport spec, final Description test) { switch (spec.getResult()) { case SUCCESS: notifier.fireTestFinished(test); return; case FAILURE: notifier.fireTestFailure(new Failure(test, spec.getCause())); return; case ERROR: default: throw new SpecificationError(spec.getMessage(), spec.getCause()); } }
Example #30
Source File: NeodymiumRunner.java From neodymium-library with MIT License | 5 votes |
@Override protected void runChild(FrameworkMethod method, RunNotifier notifier) { // clear the context before next child run Neodymium.clearThreadContext(); super.runChild(method, notifier); }