Java Code Examples for org.junit.runner.notification.RunNotifier#fireTestFinished()
The following examples show how to use
org.junit.runner.notification.RunNotifier#fireTestFinished() .
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: 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 2
Source File: DirectoryRunner.java From EasyMPermission with MIT License | 6 votes |
@Override public void run(RunNotifier notifier) { if (failure != null) { notifier.fireTestStarted(description); notifier.fireTestFailure(new Failure(description, failure)); notifier.fireTestFinished(description); return; } for (Map.Entry<String, Description> entry : tests.entrySet()) { Description testDescription = entry.getValue(); notifier.fireTestStarted(testDescription); try { if (!runTest(entry.getKey())) { notifier.fireTestIgnored(testDescription); } } catch (Throwable t) { notifier.fireTestFailure(new Failure(testDescription, t)); } notifier.fireTestFinished(testDescription); } }
Example 3
Source File: BytecoderUnitTestRunner.java From Bytecoder with Apache License 2.0 | 6 votes |
private void testJVMBackendFrameworkMethod(final FrameworkMethod aFrameworkMethod, final RunNotifier aRunNotifier) { if ("".equals(System.getProperty("BYTECODER_DISABLE_JVMTESTS", ""))) { final TestClass testClass = getTestClass(); 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)); } } }
Example 4
Source File: AbstractParallelScenarioRunner.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected Statement prepareMethodBlock(final FrameworkMethod method, final RunNotifier notifier) { final Statement methodBlock = superMethodBlock(method); return new Statement() { @Override public void evaluate() throws Throwable { try { methodBlock.evaluate(); Description description = describeChild(method); try { notifier.fireTestStarted(description); notifier.fireTestAssumptionFailed(new Failure(description, new AssumptionViolatedException("Method " + method.getName() + " did parse any input"))); } finally { notifier.fireTestFinished(description); } } catch(TestDataCarrier testData) { AbstractParallelScenarioRunner.this.testData.put(method, testData.getData()); } } }; }
Example 5
Source File: AbstractParallelScenarioRunner.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected Statement prepareMethodBlock(final FrameworkMethod method, final RunNotifier notifier) { final Statement methodBlock = superMethodBlock(method); return new Statement() { @Override public void evaluate() throws Throwable { try { methodBlock.evaluate(); Description description = describeChild(method); try { notifier.fireTestStarted(description); notifier.fireTestAssumptionFailed(new Failure(description, new AssumptionViolatedException("Method " + method.getName() + " did parse any input"))); } finally { notifier.fireTestFinished(description); } } catch(TestDataCarrier testData) { AbstractParallelScenarioRunner.this.testData.put(method, testData.getData()); } } }; }
Example 6
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 7
Source File: ScriptRunner.java From purplejs with Apache License 2.0 | 5 votes |
@Override public void run( final RunNotifier notifier ) { for ( final ScriptTestInstance file : this.testFiles ) { for ( final ScriptTestMethod method : file.getTestMethods() ) { final Description desc = Description.createTestDescription( file.getName(), method.getName() ); notifier.fireTestStarted( desc ); try { runBefore( file ); method.runTest( this.testInstance ); runAfter( file ); } catch ( final Throwable e ) { notifier.fireTestFailure( new Failure( desc, e ) ); } finally { notifier.fireTestFinished( desc ); } } file.dispose(); } }
Example 8
Source File: AbstractMultiTestRunner.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void run(RunNotifier notifier) { Description description = getDescription(); notifier.fireTestStarted(description); notifier.fireTestFailure(new Failure(description, failure)); notifier.fireTestFinished(description); }
Example 9
Source File: AbstractMultiTestRunner.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void run(RunNotifier notifier) { Description description = getDescription(); notifier.fireTestStarted(description); notifier.fireTestFailure(new Failure(description, failure)); notifier.fireTestFinished(description); }
Example 10
Source File: SafeRunner.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override public void run(final RunNotifier notifier) { notifier.fireTestStarted(suiteDescription); try { delegate.run(notifier); } catch (Throwable e) { // NOSONAR Failure failure = new Failure(suiteDescription, e); notifier.fireTestFailure(failure); captureLogsOnFailure(failure); } finally { notifier.fireTestFinished(suiteDescription); } }
Example 11
Source File: ZeroCodeUnitRunner.java From zerocode with Apache License 2.0 | 5 votes |
private void runLeafJsonTest(RunNotifier notifier, Description description, JsonTestCase jsonTestCaseAnno) { if (jsonTestCaseAnno != null) { currentTestCase = jsonTestCaseAnno.value(); } notifier.fireTestStarted(description); LOGGER.debug("### Running currentTestCase : " + currentTestCase); ScenarioSpec child = null; try { child = smartUtils.scenarioFileToJava(currentTestCase, ScenarioSpec.class); LOGGER.debug("### Found currentTestCase : -" + child); passed = multiStepsRunner.runScenario(child, notifier, description); } catch (Exception ioEx) { ioEx.printStackTrace(); notifier.fireTestFailure(new Failure(description, ioEx)); } testRunCompleted = true; if (passed) { LOGGER.info(String.format("\n**FINISHED executing all Steps for [%s] **.\nSteps were:%s", child.getScenarioName(), child.getSteps().stream() .map(step -> step.getName() == null ? step.getId() : step.getName()) .collect(Collectors.toList()))); } notifier.fireTestFinished(description); }
Example 12
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 13
Source File: ZeroCodeLoadRunner.java From zerocode with Apache License 2.0 | 5 votes |
@Override protected void runChild(TestMapping child, RunNotifier notifier) { notifier.fireTestStarted(testDescription); boolean hasFailed = loadProcessor .addTest(child.testClass(), child.testMethod()) .process(); if(hasFailed){ String failureMessage = testClass.getName() + "." + child.testMethod() + " 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 14
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 15
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 16
Source File: AbstractMultiTestRunner.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void run(RunNotifier notifier) { Description description = getDescription(); notifier.fireTestStarted(description); notifier.fireTestFailure(new Failure(description, failure)); notifier.fireTestFinished(description); }
Example 17
Source File: AbstractMultiTestRunner.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void run(RunNotifier notifier) { Description description = getDescription(); notifier.fireTestStarted(description); notifier.fireTestFailure(new Failure(description, failure)); notifier.fireTestFinished(description); }
Example 18
Source File: TestLoader.java From android-test with Apache License 2.0 | 4 votes |
@Override public void run(RunNotifier notifier) { notifier.fireTestStarted(description); notifier.fireTestFailure(failure); notifier.fireTestFinished(description); }
Example 19
Source File: BytecoderUnitTestRunner.java From Bytecoder with Apache License 2.0 | 4 votes |
private void testJSBackendFrameworkMethod(final FrameworkMethod aFrameworkMethod, final RunNotifier aRunNotifier, final TestOption aTestOption) { if ("".equals(System.getProperty("BYTECODER_DISABLE_JSTESTS", ""))) { final TestClass testClass = getTestClass(); final Description theDescription = Description.createTestDescription(testClass.getJavaClass(), aFrameworkMethod.getName() + " " + aTestOption.toDescription()); aRunNotifier.fireTestStarted(theDescription); try { final CompileTarget theCompileTarget = new CompileTarget(testClass.getJavaClass().getClassLoader(), CompileTarget.BackendType.js); final BytecodeMethodSignature theSignature = theCompileTarget.toMethodSignature(aFrameworkMethod.getMethod()); final BytecodeObjectTypeRef theTestClass = new BytecodeObjectTypeRef(testClass.getName()); final BytecodeMethodSignature theTestClassConstructorSignature = new BytecodeMethodSignature(BytecodePrimitiveTypeRef.VOID, new BytecodeTypeRef[0]); final StringWriter theStrWriter = new StringWriter(); final PrintWriter theCodeWriter = new PrintWriter(theStrWriter); final CompileOptions theOptions = new CompileOptions(LOGGER, true, KnownOptimizer.ALL, aTestOption.isExceptionsEnabled(), "bytecoder", 512, 512, aTestOption.isMinify(), aTestOption.isPreferStackifier(), Allocator.linear, additionalClassesToLink, additionalResources, null, aTestOption.isEscapeAnalysisEnabled()); final JSCompileResult result = (JSCompileResult) theCompileTarget.compile(theOptions, testClass.getJavaClass(), aFrameworkMethod.getName(), theSignature); final CompileResult.StringContent content = (CompileResult.StringContent) result.getContent()[0]; theCodeWriter.println(content.asString()); final String theFilename = result.getMinifier().toClassName(theTestClass) + "." + result.getMinifier().toMethodName(aFrameworkMethod.getName(), theSignature) + "_" + aTestOption.toFilePrefix() + ".html"; theCodeWriter.println(); theCodeWriter.println("console.log(\"Starting test\");"); theCodeWriter.println("bytecoder.bootstrap();"); theCodeWriter.println("var theTestInstance = " + result.getMinifier().toClassName(theTestClass) + "." + result.getMinifier().toSymbol("__runtimeclass") + "." + result.getMinifier().toMethodName("$newInstance", theTestClassConstructorSignature) + "();"); theCodeWriter.println("try {"); theCodeWriter.println(" theTestInstance." + result.getMinifier().toMethodName(aFrameworkMethod.getName(), theSignature) + "();"); theCodeWriter.println(" console.log(\"Test finished OK\");"); theCodeWriter.println("} catch (e) {"); theCodeWriter.println(" if (e.exception) {"); theCodeWriter.println(" console.log(\"Test finished with exception. Message = \" + bytecoder.toJSString(e.exception.message));"); theCodeWriter.println(" } else {"); theCodeWriter.println(" console.log(\"Test finished with exception.\");"); theCodeWriter.println(" }"); theCodeWriter.println(" console.log(e.stack);"); theCodeWriter.println("}"); theCodeWriter.flush(); final File theWorkingDirectory = new File("."); initializeTestWebServer(); final BrowserWebDriverContainer theContainer = initializeSeleniumContainer(); final File theMavenTargetDir = new File(theWorkingDirectory, "target"); final File theGeneratedFilesDir = new File(theMavenTargetDir, "bytecoderjs"); theGeneratedFilesDir.mkdirs(); // Copy additional resources for (final CompileResult.Content c : result.getContent()) { if (c instanceof CompileResult.URLContent) { try (final FileOutputStream fos = new FileOutputStream(new File(theGeneratedFilesDir, c.getFileName()))) { c.writeTo(fos); } } } final File theGeneratedFile = new File(theGeneratedFilesDir, theFilename); final PrintWriter theWriter = new PrintWriter(theGeneratedFile); theWriter.println("<html><body><script>"); theWriter.println(theStrWriter.toString()); theWriter.println("</script></body></html>"); theWriter.flush(); theWriter.close(); initializeWebRoot(theGeneratedFile.getParentFile()); final URL theTestURL = getTestFileUrl(theGeneratedFile); final WebDriver theDriver = theContainer.getWebDriver(); theDriver.get(theTestURL.toString()); final List<LogEntry> theAll = theDriver.manage().logs().get(LogType.BROWSER).getAll(); if (1 > theAll.size()) { aRunNotifier.fireTestFailure(new Failure(theDescription, new RuntimeException("No console output from browser"))); } for (final LogEntry theEntry : theAll) { LOGGER.info(theEntry.getMessage()); } final LogEntry theLast = theAll.get(theAll.size() - 1); if (!theLast.getMessage().contains("Test finished OK")) { aRunNotifier.fireTestFailure(new Failure(theDescription, new RuntimeException("Test did not succeed! Got : " + theLast.getMessage()))); } } catch (final Exception e) { aRunNotifier.fireTestFailure(new Failure(theDescription, e)); } finally { aRunNotifier.fireTestFinished(theDescription); } } }
Example 20
Source File: TestBasedOnSampleRunner.java From allure-java with Apache License 2.0 | 4 votes |
@Override public void run(RunNotifier notifier) { notifier.fireTestStarted(getDescription()); notifier.fireTestFinished(getDescription()); }