[ https://issues.apache.org/jira/browse/SUREFIRE-1832?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Elliotte Rusty Harold closed SUREFIRE-1832. ------------------------------------------- > Exceptions thrown in TestRules are ignored in parallel test execution > --------------------------------------------------------------------- > > Key: SUREFIRE-1832 > URL: https://issues.apache.org/jira/browse/SUREFIRE-1832 > Project: Maven Surefire > Issue Type: Bug > Affects Versions: 2.22.2 > Environment: $ mvn --version > > Apache Maven 3.6.3 > Maven home: /usr/share/maven > Java version: 1.8.0_265, vendor: Private Build, runtime: > /usr/lib/jvm/java-8-openjdk-amd64/jre > Default locale: en_US, platform encoding: UTF-8 > OS name: "linux", version: "5.4.0-42-generic", arch: "amd64", family: "unix" > $ java -version > openjdk version "1.8.0_265" > OpenJDK Runtime Environment (build 1.8.0_265-8u265-b01-0ubuntu2~20.04-b01) > OpenJDK 64-Bit Server VM (build 25.265-b01, mixed mode) > Reporter: Filipe Roque > Priority: Major > > when an exception is thrown in a JUnit TestRule and maven-surefire-plugin ins > run in parallel mode, the exception is ignored and does not break the build. > > *Unit test* > {code:java} > import static org.junit.Assert.assertTrue; > import org.junit.Rule; > import org.junit.Test; > import org.junit.rules.TestRule; > import org.junit.runner.Description; > import org.junit.runners.model.Statement; > public class TestWithRuleThatThrows > { > @Rule > public TestRuleThatThrows testRuleThatThrows = new TestRuleThatThrows(); > @Test > public void shouldAnswerWithTrue() > { > assertTrue( true ); > } > public static class TestRuleThatThrows implements TestRule { > @Override > public Statement apply(final Statement base, final Description > description) { > throw new RuntimeException("some problem"); > } > } > } > {code} > *pom.xml* > {code:xml} > <?xml version="1.0" encoding="UTF-8"?> > <project xmlns="http://maven.apache.org/POM/4.0.0" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 > http://maven.apache.org/xsd/maven-4.0.0.xsd"> > <modelVersion>4.0.0</modelVersion> > <groupId>com.mycompany.app</groupId> > <artifactId>my-app</artifactId> > <version>1.0-SNAPSHOT</version> > <name>my-app</name> > <!-- FIXME change it to the project's website --> > <url>http://www.example.com</url> > <properties> > <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> > <maven.compiler.source>1.8</maven.compiler.source> > <maven.compiler.target>1.8</maven.compiler.target> > </properties> > <dependencies> > <dependency> > <groupId>junit</groupId> > <artifactId>junit</artifactId> > <version>4.11</version> > <scope>test</scope> > </dependency> > </dependencies> > </project> > {code} > > {code:java} > $ mvn org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test > /dev/null > ; echo $? > 1 > $ mvn org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test > -Dparallel=all -DthreadCount=1 > /dev/null ; echo $? > > 0 > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)