public void update(@Observes(precedence = 99) EventContext<AfterTestLifecycleEvent> context, TestResult result) { if (State.caughtExceptionAfterJunit() != null) { if (State.caughtExceptionAfterJunit() instanceof AssumptionViolatedException) { result.setStatus(Status.SKIPPED); } else { result.setStatus(Status.FAILED); } result.setThrowable(State.caughtExceptionAfterJunit()); } else { result.setStatus(Status.PASSED); result.setThrowable(null); } context.proceed(); } }
public void update(@Observes(precedence = 99) EventContext<AfterTestLifecycleEvent> context, TestResult result) { if (State.caughtExceptionAfterJunit() != null) { if (State.caughtExceptionAfterJunit() instanceof AssumptionViolatedException) { result.setStatus(Status.SKIPPED); } else { result.setStatus(Status.FAILED); } result.setThrowable(State.caughtExceptionAfterJunit()); } else { result.setStatus(Status.PASSED); result.setThrowable(null); } context.proceed(); } }
@Override public void evaluate() throws Throwable { State.caughtExceptionAfterJunit(null); final AtomicInteger integer = new AtomicInteger(); List<Throwable> exceptions = new ArrayList<Throwable>(); stmtWithLifecycle.evaluate(); } catch (Throwable t) { State.caughtExceptionAfterJunit(t); throw t; State.caughtExceptionAfterJunit(t); exceptions.add(t); } finally { new AfterRules(test, method.getMethod(), LifecycleMethodExecutor.NO_OP)); } catch (Throwable t) { State.caughtExceptionAfterJunit(t); exceptions.add(t);
@Override public void evaluate() throws Throwable { State.caughtExceptionAfterJunit(null); final AtomicInteger integer = new AtomicInteger(); List<Throwable> exceptions = new ArrayList<Throwable>(); stmtWithLifecycle.evaluate(); } catch (Throwable t) { State.caughtExceptionAfterJunit(t); throw t; State.caughtExceptionAfterJunit(t); exceptions.add(t); } finally { new AfterRules(test, method.getMethod(), LifecycleMethodExecutor.NO_OP)); } catch (Throwable t) { State.caughtExceptionAfterJunit(t); exceptions.add(t);
@Test public void shouldFailResultIfExceptionCaughtAfterJunit() throws Exception { State.caughtExceptionAfterJunit(new AssertionError("A")); TestResult result = TestResult.failed(new NullPointerException("A")); new UpdateTestResultBeforeAfter().update(event, result); State.caughtExceptionAfterJunit(null); Assert.assertEquals(Status.FAILED, result.getStatus()); Assert.assertNotNull(result.getThrowable()); Assert.assertTrue(result.getThrowable() instanceof AssertionError); } }
@Test public void shouldFailResultIfExceptionCaughtAfterJunit() throws Exception { State.caughtExceptionAfterJunit(new AssertionError("A")); TestResult result = TestResult.failed(new NullPointerException("A")); new UpdateTestResultBeforeAfter().update(event, result); State.caughtExceptionAfterJunit(null); Assert.assertEquals(Status.FAILED, result.getStatus()); Assert.assertNotNull(result.getThrowable()); Assert.assertTrue(result.getThrowable() instanceof AssertionError); } }
@Test public void shouldSkipResultIfExceptionCaughtAfterJunit() throws Exception { State.caughtExceptionAfterJunit(new AssumptionViolatedException("A")); TestResult result = TestResult.failed(new AssumptionViolatedException("A")); new UpdateTestResultBeforeAfter().update(event, result); State.caughtExceptionAfterJunit(null); Assert.assertEquals(Status.SKIPPED, result.getStatus()); Assert.assertNotNull(result.getThrowable()); Assert.assertTrue(result.getThrowable() instanceof AssumptionViolatedException); }
@Test public void shouldSkipResultIfExceptionCaughtAfterJunit() throws Exception { State.caughtExceptionAfterJunit(new AssumptionViolatedException("A")); TestResult result = TestResult.failed(new AssumptionViolatedException("A")); new UpdateTestResultBeforeAfter().update(event, result); State.caughtExceptionAfterJunit(null); Assert.assertEquals(Status.SKIPPED, result.getStatus()); Assert.assertNotNull(result.getThrowable()); Assert.assertTrue(result.getThrowable() instanceof AssumptionViolatedException); }