@Test public void notifiedWhenMethodExecutionFailedWithError() throws Exception { adapter.executionFinished( newMethodIdentifier(), failed( new RuntimeException() ) ); verify( listener ).testError( any() ); }
@Override public void executionFinished( TestIdentifier testIdentifier, TestExecutionResult testExecutionResult ) { boolean isClass = testIdentifier.isContainer() && testIdentifier.getSource().filter( ClassSource.class::isInstance ).isPresent(); boolean isTest = testIdentifier.isTest(); boolean failed = testExecutionResult.getStatus() == FAILED; boolean isAssertionError = testExecutionResult.getThrowable() .filter( AssertionError.class::isInstance ).isPresent(); boolean isRootContainer = testIdentifier.isContainer() && !testIdentifier.getParentId().isPresent(); if ( failed || isClass || isTest ) { Integer elapsed = computeElapsedTime( testIdentifier ); switch ( testExecutionResult.getStatus() ) { case ABORTED: if ( isTest ) { runListener.testAssumptionFailure( createReportEntry( testIdentifier, testExecutionResult, elapsed ) ); } else { runListener.testSetCompleted( createReportEntry( testIdentifier, testExecutionResult, systemProps(), null, elapsed ) ); } break; case FAILED: if ( isAssertionError ) { runListener.testFailed( createReportEntry( testIdentifier, testExecutionResult, elapsed ) ); } else { runListener.testError( createReportEntry( testIdentifier, testExecutionResult, elapsed ) ); } if ( isClass || isRootContainer ) { runListener.testSetCompleted( createReportEntry( testIdentifier, null, systemProps(), null, elapsed ) ); } failures.put( testIdentifier, testExecutionResult ); break; default: if ( isTest ) { runListener.testSucceeded( createReportEntry( testIdentifier, null, elapsed ) ); } else { runListener.testSetCompleted( createReportEntry( testIdentifier, null, systemProps(), null, elapsed ) ); } } } }
RunListenerAdapter implements TestExecutionListener { @Override public void executionFinished( TestIdentifier testIdentifier, TestExecutionResult testExecutionResult ) { boolean isClass = testIdentifier.isContainer() && testIdentifier.getSource().filter( ClassSource.class::isInstance ).isPresent(); boolean isTest = testIdentifier.isTest(); boolean failed = testExecutionResult.getStatus() == FAILED; boolean isAssertionError = testExecutionResult.getThrowable() .filter( AssertionError.class::isInstance ).isPresent(); boolean isRootContainer = testIdentifier.isContainer() && !testIdentifier.getParentId().isPresent(); if ( failed || isClass || isTest ) { Integer elapsed = computeElapsedTime( testIdentifier ); switch ( testExecutionResult.getStatus() ) { case ABORTED: if ( isTest ) { runListener.testAssumptionFailure( createReportEntry( testIdentifier, testExecutionResult, elapsed ) ); } else { runListener.testSetCompleted( createReportEntry( testIdentifier, testExecutionResult, systemProps(), null, elapsed ) ); } break; case FAILED: if ( isAssertionError ) { runListener.testFailed( createReportEntry( testIdentifier, testExecutionResult, elapsed ) ); } else { runListener.testError( createReportEntry( testIdentifier, testExecutionResult, elapsed ) ); } if ( isClass || isRootContainer ) { runListener.testSetCompleted( createReportEntry( testIdentifier, null, systemProps(), null, elapsed ) ); } failures.put( testIdentifier, testExecutionResult ); break; default: if ( isTest ) { runListener.testSucceeded( createReportEntry( testIdentifier, null, elapsed ) ); } else { runListener.testSetCompleted( createReportEntry( testIdentifier, null, systemProps(), null, elapsed ) ); } } } } }
RunListenerAdapter implements TestExecutionListener { @Override public void executionFinished( TestIdentifier testIdentifier, TestExecutionResult testExecutionResult ) { boolean isClass = testIdentifier.isContainer() && testIdentifier.getSource().filter( ClassSource.class::isInstance ).isPresent(); boolean isTest = testIdentifier.isTest(); boolean failed = testExecutionResult.getStatus() == FAILED; boolean isAssertionError = testExecutionResult.getThrowable() .filter( AssertionError.class::isInstance ).isPresent(); boolean isRootContainer = testIdentifier.isContainer() && !testIdentifier.getParentId().isPresent(); if ( failed || isClass || isTest ) { Integer elapsed = computeElapsedTime( testIdentifier ); switch ( testExecutionResult.getStatus() ) { case ABORTED: if ( isTest ) { runListener.testAssumptionFailure( createReportEntry( testIdentifier, testExecutionResult, elapsed ) ); } else { runListener.testSetCompleted( createReportEntry( testIdentifier, testExecutionResult, systemProps(), null, elapsed ) ); } break; case FAILED: if ( isAssertionError ) { runListener.testFailed( createReportEntry( testIdentifier, testExecutionResult, elapsed ) ); } else { runListener.testError( createReportEntry( testIdentifier, testExecutionResult, elapsed ) ); } if ( isClass || isRootContainer ) { runListener.testSetCompleted( createReportEntry( testIdentifier, null, systemProps(), null, elapsed ) ); } failures.put( testIdentifier, testExecutionResult ); break; default: if ( isTest ) { runListener.testSucceeded( createReportEntry( testIdentifier, null, elapsed ) ); } else { runListener.testSetCompleted( createReportEntry( testIdentifier, null, systemProps(), null, elapsed ) ); } } } } RunListenerAdapter( RunListener runListener ); }
RunListenerAdapter implements TestExecutionListener { @Override public void executionFinished( TestIdentifier testIdentifier, TestExecutionResult testExecutionResult ) { boolean isClass = testIdentifier.isContainer() && testIdentifier.getSource().filter( ClassSource.class::isInstance ).isPresent(); boolean isTest = testIdentifier.isTest(); boolean failed = testExecutionResult.getStatus() == FAILED; boolean isAssertionError = testExecutionResult.getThrowable() .filter( AssertionError.class::isInstance ).isPresent(); boolean isRootContainer = testIdentifier.isContainer() && !testIdentifier.getParentId().isPresent(); if ( failed || isClass || isTest ) { Integer elapsed = computeElapsedTime( testIdentifier ); switch ( testExecutionResult.getStatus() ) { case ABORTED: if ( isTest ) { runListener.testAssumptionFailure( createReportEntry( testIdentifier, testExecutionResult, elapsed ) ); } else { runListener.testSetCompleted( createReportEntry( testIdentifier, testExecutionResult, systemProps(), null, elapsed ) ); } break; case FAILED: if ( isAssertionError ) { runListener.testFailed( createReportEntry( testIdentifier, testExecutionResult, elapsed ) ); } else { runListener.testError( createReportEntry( testIdentifier, testExecutionResult, elapsed ) ); } if ( isClass || isRootContainer ) { runListener.testSetCompleted( createReportEntry( testIdentifier, null, systemProps(), null, elapsed ) ); } failures.put( testIdentifier, testExecutionResult ); break; default: if ( isTest ) { runListener.testSucceeded( createReportEntry( testIdentifier, null, elapsed ) ); } else { runListener.testSetCompleted( createReportEntry( testIdentifier, null, systemProps(), null, elapsed ) ); } } } } RunListenerAdapter( RunListener runListener ); @Override void testPlanExecutionStarted( TestPlan testPlan ); @Override void testPlanExecutionFinished( TestPlan testPlan ); @Override void executionStarted( TestIdentifier testIdentifier ); @Override void executionFinished( TestIdentifier testIdentifier, TestExecutionResult testExecutionResult ); @Override void executionSkipped( TestIdentifier testIdentifier, String reason ); }
RunListenerAdapter implements TestExecutionListener { @Override public void executionFinished( TestIdentifier testIdentifier, TestExecutionResult testExecutionResult ) { boolean isClass = testIdentifier.isContainer() && testIdentifier.getSource().filter( ClassSource.class::isInstance ).isPresent(); boolean isTest = testIdentifier.isTest(); boolean failed = testExecutionResult.getStatus() == FAILED; boolean isAssertionError = testExecutionResult.getThrowable() .filter( AssertionError.class::isInstance ).isPresent(); boolean isRootContainer = testIdentifier.isContainer() && !testIdentifier.getParentId().isPresent(); if ( failed || isClass || isTest ) { Integer elapsed = computeElapsedTime( testIdentifier ); switch ( testExecutionResult.getStatus() ) { case ABORTED: if ( isTest ) { runListener.testAssumptionFailure( createReportEntry( testIdentifier, testExecutionResult, elapsed ) ); } else { runListener.testSetCompleted( createReportEntry( testIdentifier, testExecutionResult, systemProps(), null, elapsed ) ); } break; case FAILED: if ( isAssertionError ) { runListener.testFailed( createReportEntry( testIdentifier, testExecutionResult, elapsed ) ); } else { runListener.testError( createReportEntry( testIdentifier, testExecutionResult, elapsed ) ); } if ( isClass || isRootContainer ) { runListener.testSetCompleted( createReportEntry( testIdentifier, null, systemProps(), null, elapsed ) ); } failures.put( testIdentifier, testExecutionResult ); break; default: if ( isTest ) { runListener.testSucceeded( createReportEntry( testIdentifier, null, elapsed ) ); } else { runListener.testSetCompleted( createReportEntry( testIdentifier, null, systemProps(), null, elapsed ) ); } } } } RunListenerAdapter( RunListener runListener ); @Override void testPlanExecutionStarted( TestPlan testPlan ); @Override void testPlanExecutionFinished( TestPlan testPlan ); @Override void executionStarted( TestIdentifier testIdentifier ); @Override void executionFinished( TestIdentifier testIdentifier, TestExecutionResult testExecutionResult ); @Override void executionSkipped( TestIdentifier testIdentifier, String reason );  }