[ 
https://issues.apache.org/jira/browse/SUREFIRE-1525?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16836575#comment-16836575
 ] 

Matt Nelson commented on SUREFIRE-1525:
---------------------------------------

Noticing the same issue with AfterClass.

> 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)

Reply via email to