Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2009, Red Hat Middleware LLC, and individual contributors
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
  * http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.jboss.arquillian.testng;
 
 import static org.mockito.Matchers.isA;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import org.junit.Test;
Verify the that JUnit integration adaptor fires the expected events even when Handlers are failing.

Author(s):
Aslak Knutsen
Version:
$Revision: $
 
 {
    @Test @Ignore("ARQ-582")
    {
       TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
       when(adaptor.test(isA(TestMethodExecutor.class))).thenReturn(new TestResult(.));
 
       TestListenerAdapter result = run(adaptorArquillianClass1.class);
 
       Assert.assertTrue(wasSuccessful(result));
       assertCycle(0, Cycle.values());
 
    }
 
    @Test
    public void shouldCallAllMethods() throws Exception
    {
       TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
       executeAllLifeCycles(adaptor);
 
       TestListenerAdapter result = run(adaptorArquillianClass1.class);
 
       Assert.assertTrue(wasSuccessful(result));
       assertCycle(1, Cycle.values());
 
    }
 
    @Test
    {
       TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
       executeAllLifeCycles(adaptor);
 
       throwException(.new Throwable());
 
       TestListenerAdapter result = run(adaptorArquillianClass1.class);
       Assert.assertFalse(wasSuccessful(result));
 
       assertCycle(0, ...);
 
       verify(adaptortimes(1)).beforeSuite();
       verify(adaptortimes(1)).afterSuite();
    }
 
    @Test
    public void shouldCallAfterWhenBeforeThrowsException() throws Exception
    {
       TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
       executeAllLifeCycles(adaptor);
 
       throwException(.new Throwable());
 
      TestListenerAdapter result = run(adaptorArquillianClass1.class);
      Assert.assertFalse(wasSuccessful(result));
      assertCycle(0, .);
   }
   @Test
   {
      TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
      executeAllLifeCycles(adaptor);
      // throwException removes exception marker when thrown
      TestListenerAdapter result = run(adaptorArquillianClass1.classArquillianClass2.class);
      Assert.assertFalse(wasSuccessful(result));
   }
   @Test
   public void shouldOnlyCallBeforeAfterSuiteOnce() throws Exception
   {
      TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
      executeAllLifeCycles(adaptor);
      TestListenerAdapter result = run(adaptorArquillianClass1.classArquillianClass2.class);
      Assert.assertTrue(wasSuccessful(result));
   }
   @Test
   public void shouldCallAllWhenTestThrowsException() throws Exception
   {
      TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
      executeAllLifeCycles(adaptor);
      throwException(.new Throwable());
      TestListenerAdapter result = run(adaptorArquillianClass1.class);
      Assert.assertFalse(wasSuccessful(result));
      assertCycle(1, Cycle.values());
   }
   @Test
   {
      TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
      executeAllLifeCycles(adaptor);
      TestListenerAdapter result = run(adaptorNonArquillianClass1.class);
      Assert.assertTrue(wasSuccessful(result));
      assertCycle(0, Cycle.values());
   }
   @Test
   {
      TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
      executeAllLifeCycles(adaptor);
      TestListenerAdapter result = run(new String[]{"non-arq"}, adaptorNonArquillianClass1.classArquillianClass1.class);
      Assert.assertTrue(wasSuccessful(result));
      assertCycle(0, Cycle.values());
   }
   @Test @Ignore("ARQ-646")
   public void shouldCallArquillianWhenGroupIsRan() throws Exception
   {
      TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
      executeAllLifeCycles(adaptor);
      TestListenerAdapter result = run(new String[]{"arq"}, adaptorNonArquillianClass1.classArquillianClass2.class);
      Assert.assertTrue(wasSuccessful(result));
      assertCycle(1, Cycle.values());
   }
   @Test // workaround for ARQ-646, enable the arquillian group
   {
      TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
      executeAllLifeCycles(adaptor);
      TestListenerAdapter result = run(new String[]{"arq""arquillian"}, adaptorNonArquillianClass1.classArquillianClass2.class);
      Assert.assertTrue(wasSuccessful(result));
      assertCycle(1, Cycle.values());
   }
New to GrepCode? Check out our FAQ X