[arquillian-issues] [JBoss JIRA] (ARQ-1773) JUnittests pass when exception is thrown from @Before-annotated method

Mattias Persson (JIRA) issues at jboss.org
Mon May 12 06:29:57 EDT 2014


     [ https://issues.jboss.org/browse/ARQ-1773?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mattias Persson updated ARQ-1773:
---------------------------------

    Steps to Reproduce: 
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);
    }    

}

  was:
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);
    }    

}



> JUnittests pass when exception is thrown from @Before-annotated method
> ----------------------------------------------------------------------
>
>                 Key: ARQ-1773
>                 URL: https://issues.jboss.org/browse/ARQ-1773
>             Project: Arquillian
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Base Implementation
>    Affects Versions: 1.1.4.Final
>            Reporter: Mattias Persson
>         Attachments: arquillian_test_should_fail.zip
>
>
> 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.



--
This message was sent by Atlassian JIRA
(v6.2.3#6260)


More information about the arquillian-issues mailing list