Uploaded image for project: 'Arquillian'
  1. Arquillian
  2. ARQ-1773

JUnittests pass when exception is thrown from @Before-annotated method

    XMLWordPrintable

Details

    • Hide

      See attached file

      Maven dependency according to:
      <dependencyManagement>
      <dependencies>
      <dependency>
      <groupId>org.jboss.arquillian</groupId>
      <artifactId>arquillian-bom</artifactId>
      <version>1.1.4.Final</version>
      <scope>import</scope>
      <type>pom</type>
      </dependency>
      </dependencies>
      </dependencyManagement>

      Testclass according to:

      package se.shouldfailtest;

      import org.jboss.arquillian.container.test.api.Deployment;
      import org.jboss.arquillian.junit.Arquillian;
      import org.jboss.shrinkwrap.api.Archive;
      import org.jboss.shrinkwrap.api.ShrinkWrap;
      import org.jboss.shrinkwrap.api.asset.EmptyAsset;
      import org.jboss.shrinkwrap.api.spec.WebArchive;
      import org.junit.Before;
      import org.junit.Test;
      import org.junit.runner.RunWith;

      import static org.junit.Assert.assertTrue;

      @RunWith(Arquillian.class)
      public class ShouldFailTest {
      @Deployment
      public static Archive<?> createDeployment()

      { WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war") .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); return war; }

      @Before
      public void preparePersistenceTest() throws Exception

      { throw new Exception("Test should fail when exception is thrown in @Before..."); }

      @Test
      public void shouldFail() throws Exception

      { //This test will pass in 1.1.4.Final but not in 1.1.3.Final (as expected). assertTrue(false); }

      }

      Show
      See attached file Maven dependency according to: <dependencyManagement> <dependencies> <dependency> <groupId>org.jboss.arquillian</groupId> <artifactId>arquillian-bom</artifactId> <version>1.1.4.Final</version> <scope>import</scope> <type>pom</type> </dependency> </dependencies> </dependencyManagement> Testclass according to: package se.shouldfailtest; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertTrue; @RunWith(Arquillian.class) public class ShouldFailTest { @Deployment public static Archive<?> createDeployment() { WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war") .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); return war; } @Before public void preparePersistenceTest() throws Exception { throw new Exception("Test should fail when exception is thrown in @Before..."); } @Test public void shouldFail() throws Exception { //This test will pass in 1.1.4.Final but not in 1.1.3.Final (as expected). assertTrue(false); } }

    Description

      When an exception is thrown from a method with @Before, tests that should fail actually pass when using Arquillian 1.1.4.Final. When stepping down to 1.1.3.Final, the tests fail as expected.

      Attachments

        Activity

          People

            aslak@redhat.com Aslak Knutsen
            mape_jira Mattias Persson (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: