@Test public void shouldReturnExceptionThrownInBeforeToClientWhenTestFails() throws Exception { Exception expectedException = new Exception("Expected"); TestScenarios.exceptionThrownInBefore = expectedException; Exception unexpectedException = new Exception("Not expected"); TestScenarios.exceptionThrownInAfter = unexpectedException; JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldFailOnException"); Assert.assertEquals(TestResult.Status.FAILED, result.getStatus()); Assert.assertSame(expectedException, result.getThrowable()); }
@Test public void shouldReturnExceptionThrownInAfterClientWhenTestSucceeds() throws Exception { Exception expectedException = new Exception("Expected"); TestScenarios.exceptionThrownInAfter = expectedException; JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldSucceed"); Assert.assertEquals(TestResult.Status.FAILED, result.getStatus()); Assert.assertSame(expectedException, result.getThrowable()); }
@Test public void shouldReturnAssertionErrorToClientWhenAfterThrowsException() throws Exception { Exception unexpectedException = new Exception("Not expected"); TestScenarios.exceptionThrownInAfter = unexpectedException; JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldFailOnException"); Assert.assertEquals(TestResult.Status.FAILED, result.getStatus()); Assert.assertNotNull(result.getThrowable()); Assert.assertEquals(AssertionError.class, result.getThrowable().getClass()); }
@Test public void shouldReturnExceptionToClientIfAnnotatedExpectedAndFailingOnWrongExceptionThrown() throws Exception { State.caughtTestException(new UnsupportedOperationException()); JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldFailAnnotatedExpectedWrongException"); Assert.assertEquals(TestResult.Status.FAILED, result.getStatus()); Assert.assertNotNull(result.getThrowable()); Assert.assertEquals(UnsupportedOperationException.class, result.getThrowable().getClass()); }
@Test public void shouldReturnExceptionToClientIfAnnotatedExpectedAndPassing() throws Exception { State.caughtTestException(new IllegalArgumentException()); JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldPassAnnotatedExpected"); Assert.assertEquals(TestResult.Status.PASSED, result.getStatus()); Assert.assertNotNull(result.getThrowable()); Assert.assertEquals(IllegalArgumentException.class, result.getThrowable().getClass()); }
@Test public void shouldNotReturnExceptionToClientIfExpectedRulePassing() throws Exception { State.caughtTestException(new IllegalArgumentException()); JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldPassOnException"); Assert.assertEquals(TestResult.Status.PASSED, result.getStatus()); Assert.assertNull(result.getThrowable()); }
@Test public void shouldReturnExceptionToClientIfAsumptionFailing() throws Exception { JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldSkipOnAssumption"); Assert.assertEquals(TestResult.Status.SKIPPED, result.getStatus()); Assert.assertNotNull(result.getThrowable()); Assert.assertEquals(AssumptionViolatedException.class, result.getThrowable().getClass()); }
@Test public void shouldReturnExceptionToClientIfExpectedRuleFailing() throws Exception { JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldFailOnException"); Assert.assertEquals(TestResult.Status.FAILED, result.getStatus()); Assert.assertNotNull(result.getThrowable()); Assert.assertEquals(AssertionError.class, result.getThrowable().getClass()); }
@Test public void shouldNotReturnExceptionToClientIfAnnotatedExpectedAndFailingOnNoExceptionThrown() throws Exception { JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldFailAnnotatedExpected"); Assert.assertEquals(TestResult.Status.FAILED, result.getStatus()); Assert.assertNull(result.getThrowable()); //Assert.assertEquals(IllegalArgumentException.class, result.getThrowable().getClass()); }
@Test public void shouldNotReturnExceptionToClientIfAsumptionPassing() throws Exception { JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldPassOnAssumption"); Assert.assertEquals(TestResult.Status.PASSED, result.getStatus()); Assert.assertNull(result.getThrowable()); }
@Test public void shouldReturnExceptionThrownInBeforeToClientWhenTestFails() throws Exception { Exception expectedException = new Exception("Expected"); TestScenarios.exceptionThrownInBefore = expectedException; Exception unexpectedException = new Exception("Not expected"); TestScenarios.exceptionThrownInAfter = unexpectedException; JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldFailOnException"); Assert.assertEquals(TestResult.Status.FAILED, result.getStatus()); Assert.assertSame(expectedException, result.getThrowable()); }
@Test public void shouldReturnExceptionThrownInAfterClientWhenTestSucceeds() throws Exception { Exception expectedException = new Exception("Expected"); TestScenarios.exceptionThrownInAfter = expectedException; JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldSucceed"); Assert.assertEquals(TestResult.Status.FAILED, result.getStatus()); Assert.assertSame(expectedException, result.getThrowable()); }
@Test public void shouldReturnAssertionErrorToClientWhenAfterThrowsException() throws Exception { Exception unexpectedException = new Exception("Not expected"); TestScenarios.exceptionThrownInAfter = unexpectedException; JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldFailOnException"); Assert.assertEquals(TestResult.Status.FAILED, result.getStatus()); Assert.assertNotNull(result.getThrowable()); Assert.assertEquals(AssertionError.class, result.getThrowable().getClass()); }
@Test public void shouldNotReturnExceptionToClientIfExpectedRulePassing() throws Exception { State.caughtTestException(new IllegalArgumentException()); JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldPassOnException"); Assert.assertEquals(TestResult.Status.PASSED, result.getStatus()); Assert.assertNull(result.getThrowable()); }
@Test public void shouldReturnExceptionToClientIfAnnotatedExpectedAndFailingOnWrongExceptionThrown() throws Exception { State.caughtTestException(new UnsupportedOperationException()); JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldFailAnnotatedExpectedWrongException"); Assert.assertEquals(TestResult.Status.FAILED, result.getStatus()); Assert.assertNotNull(result.getThrowable()); Assert.assertEquals(UnsupportedOperationException.class, result.getThrowable().getClass()); }
@Test public void shouldReturnExceptionToClientIfAnnotatedExpectedAndPassing() throws Exception { State.caughtTestException(new IllegalArgumentException()); JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldPassAnnotatedExpected"); Assert.assertEquals(TestResult.Status.PASSED, result.getStatus()); Assert.assertNotNull(result.getThrowable()); Assert.assertEquals(IllegalArgumentException.class, result.getThrowable().getClass()); }
@Test public void shouldReturnExceptionToClientIfExpectedRuleFailing() throws Exception { JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldFailOnException"); Assert.assertEquals(TestResult.Status.FAILED, result.getStatus()); Assert.assertNotNull(result.getThrowable()); Assert.assertEquals(AssertionError.class, result.getThrowable().getClass()); }
@Test public void shouldNotReturnExceptionToClientIfAnnotatedExpectedAndFailingOnNoExceptionThrown() throws Exception { JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldFailAnnotatedExpected"); Assert.assertEquals(TestResult.Status.FAILED, result.getStatus()); Assert.assertNull(result.getThrowable()); //Assert.assertEquals(IllegalArgumentException.class, result.getThrowable().getClass()); }
@Test public void shouldReturnExceptionToClientIfAsumptionFailing() throws Exception { JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldSkipOnAssumption"); Assert.assertEquals(TestResult.Status.SKIPPED, result.getStatus()); Assert.assertNotNull(result.getThrowable()); Assert.assertEquals(AssumptionViolatedException.class, result.getThrowable().getClass()); }
@Test public void shouldNotReturnExceptionToClientIfAsumptionPassing() throws Exception { JUnitTestRunner runner = new JUnitTestRunner(); TestResult result = runner.execute(TestScenarios.class, "shouldPassOnAssumption"); Assert.assertEquals(TestResult.Status.PASSED, result.getStatus()); Assert.assertNull(result.getThrowable()); }