maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivan Syarov (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (SUREFIRE-1525) Exception in a @BeforeClass method in a JUnit suite class does not fail the build if ran in parallel
Date Tue, 12 Jun 2018 10:28:00 GMT

     [ https://issues.apache.org/jira/browse/SUREFIRE-1525?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Ivan Syarov updated SUREFIRE-1525:
----------------------------------
    Description: 
I have a @BeforeClass annotated method in a JUnit test suite class, and if an exception is
thrown in the method, the parallel build either succeeds if the *-DfailIfNoTests* parameter
is set to false or fails with "No tests were executed" if the parameter is set to true. If
the build is started without the *parallel* parameter it fails as it should.

I used a simple project setup to reproduce. I have two test classes, each with one test method
and a suite class:

*TestA.class*
{code:java}
public class TestA {
    @Test
    public void test() {
        System.out.println("TestA");
    }
}
{code}
*TestB.class*
{code:java}
public class TestB {
    @Test
    public void test() {
        System.out.println("TestB");
    }
}
{code}
*TestSuite.class*
{code:java}
@RunWith(Suite.class)
@SuiteClasses({TestA.class, TestB.class})
public class TestSuite {
    @BeforeClass
    public static void setUp() {
        throw new RuntimeException("ex");
    }
}
{code}
If i execute:

mvn clean install  -Dtest=TestSuite -Dparallel=classes -DthreadCount=2 -DfailIfNoTests=false

the build succeeds. If I omit the -DfailIfNoTests=false the build fails, but not because of
the thrown exception, but with "No tests were executed!". If i omit the parallel parameter
the build fails appropriately with "There are test failures."

The JUnit version is 4.12

The surefire plugin version is 2.19.1 - 2.21.0

 

  was:
I have a @BeforeClass annotated method in a JUnit test suite class, and if an exception is
thrown in the method, the parallel build either succeeds if the *-DfailIfNoTests* parameter
is set to false or fails with "No tests were executed" if the parameter is set to true. If
the build is started without the *parallel* parameter it fails as it should.

I used a simple project setup to reproduce. I have two test classes, each with one test method
and a suite class:

*TestA.class*
{code:java}
public class TestA {
    @Test
    public void test() {
        System.out.println("TestA");
    }
}
{code}
*TestB.class*
{code:java}
public class TestB {
    @Test
    public void test() {
        System.out.println("TestB");
    }
}
{code}
*TestSuite.class*
{code:java}
@RunWith(Suite.class)
@SuiteClasses({TestA.class, TestB.class})
public class TestSuite {
    @BeforeClass
    public static void setUp() {
        throw new RuntimeException("ex");
    }
}
{code}
If i execute:

mvn clean install  -Dtest=TestSuite -Dparallel=classes -DthreadCount=2 -DfailIfNoTests=false

the build succeeds. If I omit the -DfailIfNoTests=false the build fails, but not because of
the thrown exception, but with "No tests were executed!". If i omit the parallel parameter
the build fails appropriately with "There are test failures."

The JUnit version is 4.12

The failsafe plugin version is 2.19.1 - 2.21.0

 


> Exception in a @BeforeClass method in a JUnit suite class does not fail the build if
ran in parallel
> ----------------------------------------------------------------------------------------------------
>
>                 Key: SUREFIRE-1525
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1525
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: Junit 4.7+ (parallel) support
>    Affects Versions: 2.21.0
>            Reporter: Ivan Syarov
>            Priority: Major
>
> I have a @BeforeClass annotated method in a JUnit test suite class, and if an exception
is thrown in the method, the parallel build either succeeds if the *-DfailIfNoTests* parameter
is set to false or fails with "No tests were executed" if the parameter is set to true. If
the build is started without the *parallel* parameter it fails as it should.
> I used a simple project setup to reproduce. I have two test classes, each with one test
method and a suite class:
> *TestA.class*
> {code:java}
> public class TestA {
>     @Test
>     public void test() {
>         System.out.println("TestA");
>     }
> }
> {code}
> *TestB.class*
> {code:java}
> public class TestB {
>     @Test
>     public void test() {
>         System.out.println("TestB");
>     }
> }
> {code}
> *TestSuite.class*
> {code:java}
> @RunWith(Suite.class)
> @SuiteClasses({TestA.class, TestB.class})
> public class TestSuite {
>     @BeforeClass
>     public static void setUp() {
>         throw new RuntimeException("ex");
>     }
> }
> {code}
> If i execute:
> mvn clean install  -Dtest=TestSuite -Dparallel=classes -DthreadCount=2 -DfailIfNoTests=false
> the build succeeds. If I omit the -DfailIfNoTests=false the build fails, but not because
of the thrown exception, but with "No tests were executed!". If i omit the parallel parameter
the build fails appropriately with "There are test failures."
> The JUnit version is 4.12
> The surefire plugin version is 2.19.1 - 2.21.0
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message