Ivan Syarov created SUREFIRE-1525:
-------------------------------------
Summary: 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
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*
public class TestA {
@Test
public void test() {
System.out.println("TestA");
}
}
*TestB.class*
public class TestB {
@Test
public void test() {
System.out.println("TestB");
}
}
*TestSuite.class*
@RunWith(Suite.class)
@SuiteClasses(\{TestA.class, TestB.class})
public class TestSuite {
@BeforeClass
public static void setUp() {
throw new RuntimeException("ex");
}
}
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."
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)