@Test public void shouldOnlyCallBeforeAfterSuiteOnce() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); Result result = run(adaptor, ClassWithArquillianClassAndMethodRule.class, ClassWithArquillianClassAndMethodRule.class, ClassWithArquillianClassAndMethodRule.class, ClassWithArquillianClassAndMethodRule.class); Assert.assertTrue(result.wasSuccessful()); verify(adaptor, times(4)).beforeSuite(); verify(adaptor, times(4)).afterSuite(); }
@Test public void shouldOnlyCallBeforeAfterSuiteOnce() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); Result result = run(adaptor, ClassWithArquillianRunner.class, ClassWithArquillianRunner.class, ClassWithArquillianRunner.class, ClassWithArquillianRunner.class); Assert.assertTrue(result.wasSuccessful()); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }
@Test public void shouldOnlyCallBeforeAfterSuiteOnce() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); Result result = run(adaptor, ClassWithArquillianRunner.class, ClassWithArquillianRunner.class, ClassWithArquillianRunner.class, ClassWithArquillianRunner.class); Assert.assertTrue(result.wasSuccessful()); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }
@Test public void shouldWorkWithExpectedExceptionRule() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); Result result = run(adaptor, ClassWithArquillianClassAndMethodRuleWithExpectedExceptionRule.class); Assert.assertTrue(result.wasSuccessful()); assertCycle(1, Cycle.BEFORE_CLASS, Cycle.BEFORE, Cycle.TEST, Cycle.AFTER, Cycle.AFTER_CLASS); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }
@Test public void shouldWorkWithExpectedException() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); Result result = run(adaptor, ClassWithArquillianClassAndMethodRuleWithExpectedException.class); Assert.assertTrue(result.wasSuccessful()); assertCycle(1, Cycle.BEFORE_CLASS, Cycle.BEFORE, Cycle.TEST, Cycle.AFTER, Cycle.AFTER_CLASS); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }
@Test public void shouldWorkWithExpectedException() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); Result result = run(adaptor, ClassWithArquillianRunnerWithExpectedException.class); Assert.assertTrue(result.wasSuccessful()); assertCycle(1, Cycle.BEFORE_CLASS, Cycle.BEFORE, Cycle.TEST, Cycle.AFTER, Cycle.AFTER_CLASS); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }
@Test public void shouldWorkWithExpectedExceptionRule() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); Result result = run(adaptor, ClassWithArquillianClassAndMethodRuleWithExpectedExceptionRule.class); Assert.assertTrue(result.wasSuccessful()); assertCycle(1, Cycle.BEFORE_CLASS, Cycle.BEFORE, Cycle.TEST, Cycle.AFTER, Cycle.AFTER_CLASS); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }
@Test public void shouldCallAllMethodsWithRealAdapter() throws Exception { System.setProperty("arquillian.debug", "true"); TestRunnerAdaptor adaptor = spy(TestRunnerAdaptorBuilder.build()); Result result = run(adaptor, ArquillianClass1.class); Assert.assertTrue(result.wasSuccessful()); assertCycle(1, Cycle.values()); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); } }
@Test public void shouldWorkWithExpectedException() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); Result result = run(adaptor, ClassWithArquillianRunnerWithExpectedException.class); Assert.assertTrue(result.wasSuccessful()); assertCycle(1, Cycle.BEFORE_CLASS, Cycle.BEFORE, Cycle.TEST, Cycle.AFTER, Cycle.AFTER_CLASS); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }
@Test public void shouldWorkWithExpectedExceptionRule() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); Result result = run(adaptor, ClassWithArquillianRunnerWithExpectedExceptionRule.class); Assert.assertTrue(result.wasSuccessful()); assertCycle(1, Cycle.BEFORE_CLASS, Cycle.BEFORE, Cycle.TEST, Cycle.AFTER, Cycle.AFTER_CLASS); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }
@Test public void shouldCallAllMethodsWithRealAdapter() throws Exception { System.setProperty("arquillian.debug", "true"); TestRunnerAdaptor adaptor = spy(TestRunnerAdaptorBuilder.build()); Result result = run(adaptor, ArquillianClass1.class); Assert.assertTrue(result.wasSuccessful()); assertCycle(1, Cycle.values()); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); } }
@Test public void shouldCallAllWhenTestThrowsException() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); throwException(Cycle.TEST, new Throwable()); Result result = run(adaptor, ClassWithArquillianRunner.class); Assert.assertFalse(result.wasSuccessful()); assertCycle(1, Cycle.basics()); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }
@Test public void shouldWorkWithTimeout() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); Result result = run(adaptor, ClassWithArquillianClassAndMethodRuleWithTimeout.class); Assert.assertFalse(result.wasSuccessful()); Assert.assertTrue(result.getFailures().get(0).getMessage().contains("timed out")); assertCycle(1, Cycle.BEFORE_CLASS, Cycle.BEFORE, Cycle.AFTER, Cycle.AFTER_CLASS); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }
@Test public void shouldWorkWithTimeout() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); Result result = run(adaptor, ClassWithArquillianRunnerWithTimeout.class); Assert.assertFalse(result.wasSuccessful()); Assert.assertTrue(result.getFailures().get(0).getMessage().contains("timed out")); assertCycle(1, Cycle.BEFORE_CLASS, Cycle.BEFORE, Cycle.AFTER, Cycle.AFTER_CLASS); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }
@Test public void shouldCallAfterClassWhenBeforeThrowsException() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); throwException(Cycle.BEFORE_CLASS, new Throwable()); TestListenerAdapter result = run(adaptor, ArquillianClass1.class); Assert.assertFalse(wasSuccessful(result)); assertCycle(1, Cycle.BEFORE_CLASS, Cycle.AFTER_CLASS); assertCycle(0, Cycle.BEFORE, Cycle.AFTER, Cycle.TEST); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }
@Test public void shouldNotCallAnyMethodsWithoutLifecycleHandlers() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); when(adaptor.test(isA(TestMethodExecutor.class))).thenReturn(TestResult.passed()); Result result = run(adaptor, ClassWithArquillianRunner.class); Assert.assertTrue(result.wasSuccessful()); assertCycle(0, Cycle.basics()); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }
@Test public void shouldCallAllMethods() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); Result result = run(adaptor, ClassWithArquillianRunner.class); Assert.assertTrue(result.wasSuccessful()); assertCycle(1, Cycle.basics()); verify(adaptor, times(1)).fireCustomLifecycle(isA(BeforeRules.class)); verify(adaptor, times(1)).fireCustomLifecycle(isA(AfterRules.class)); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }
@Test public void shouldCallAfterWhenBeforeThrowsException() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); throwException(Cycle.BEFORE, new Throwable()); Result result = run(adaptor, ClassWithArquillianRunner.class); Assert.assertFalse(result.wasSuccessful()); assertCycle(1, Cycle.BEFORE_CLASS, Cycle.AFTER_CLASS, Cycle.BEFORE, Cycle.AFTER); assertCycle(0, Cycle.TEST); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }
@Test public void shouldCallAllMethods() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); Result result = run(adaptor, ClassWithArquillianClassAndMethodRule.class); Assert.assertTrue(result.wasSuccessful()); assertCycle(1, Cycle.basics()); verify(adaptor, times(1)).fireCustomLifecycle(isA(BeforeRules.class)); verify(adaptor, times(1)).fireCustomLifecycle(isA(AfterRules.class)); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }
@Test public void shouldCallAllWhenTestThrowsException() throws Exception { TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class); executeAllLifeCycles(adaptor); throwException(Cycle.TEST, new Throwable()); Result result = run(adaptor, ClassWithArquillianClassAndMethodRule.class); Assert.assertFalse(result.wasSuccessful()); assertCycle(1, Cycle.basics()); verify(adaptor, times(1)).beforeSuite(); verify(adaptor, times(1)).afterSuite(); }