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

Jiri Daněk updated SUREFIRE-1577:
---------------------------------
    Issue Type: Bug  (was: Test)

> JUnit 5 surefire-provider ignores configuration properties in POM
> -----------------------------------------------------------------
>
>                 Key: SUREFIRE-1577
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1577
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: JUnit 5.x support, Maven Surefire Plugin
>    Affects Versions: 2.22.0
>            Reporter: Jiri Daněk
>            Priority: Major
>
> I wanted to exclude some tags using
> {noformat}
>                                       <properties>
>                                               
> <excludeTags>external</excludeTags>
>                                       </properties>
> {noformat}
> but the test tagged thus was still run by surefire.
> h3. Reproducer
> I took the junit5 sample project 
> https://github.com/junit-team/junit5-samples/tree/r5.3.1/junit5-jupiter-starter-maven
>  and added a tag to one test. I now want to skip running this test. (Ignore 
> the commented out xml now.)
> {code}
> diff --git a/junit5-jupiter-starter-maven/pom.xml 
> b/junit5-jupiter-starter-maven/pom.xml
> index 6c217cf..27ec850 100644
> --- a/junit5-jupiter-starter-maven/pom.xml
> +++ b/junit5-jupiter-starter-maven/pom.xml
> @@ -13,6 +13,8 @@
>               
> <maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
>  
>               <junit.jupiter.version>5.3.1</junit.jupiter.version>
> +
> +             <!--<junit.platform.version>1.3.1</junit.platform.version>-->
>       </properties>
>  
>       <dependencies>
> @@ -42,6 +44,18 @@
>                       <plugin>
>                               <artifactId>maven-surefire-plugin</artifactId>
>                               <version>2.22.0</version>
> +                             <configuration>
> +                                     <properties>
> +                                             
> <excludeTags>external</excludeTags>
> +                                     </properties>
> +                             </configuration>
> +                             <!--<dependencies>-->
> +                                     <!--<dependency>-->
> +                                             
> <!--<groupId>org.junit.platform</groupId>-->
> +                                             
> <!--<artifactId>junit-platform-surefire-provider</artifactId>-->
> +                                             
> <!--<version>${junit.platform.version}</version>-->
> +                                     <!--</dependency>-->
> +                             <!--</dependencies>-->
>                       </plugin>
>               </plugins>
>       </build>
> diff --git 
> a/junit5-jupiter-starter-maven/src/test/java/com/example/project/CalculatorTests.java
>  
> b/junit5-jupiter-starter-maven/src/test/java/com/example/project/CalculatorTests.java
> index 0d4f546..8994070 100644
> --- 
> a/junit5-jupiter-starter-maven/src/test/java/com/example/project/CalculatorTests.java
> +++ 
> b/junit5-jupiter-starter-maven/src/test/java/com/example/project/CalculatorTests.java
> @@ -11,8 +11,10 @@
>  package com.example.project;
>  
>  import static org.junit.jupiter.api.Assertions.assertEquals;
> +import static org.junit.jupiter.api.Assertions.fail;
>  
>  import org.junit.jupiter.api.DisplayName;
> +import org.junit.jupiter.api.Tag;
>  import org.junit.jupiter.api.Test;
>  import org.junit.jupiter.params.ParameterizedTest;
>  import org.junit.jupiter.params.provider.CsvSource;
> @@ -20,8 +22,10 @@ import org.junit.jupiter.params.provider.CsvSource;
>  class CalculatorTests {
>  
>       @Test
> +     @Tag("external")
>       @DisplayName("1 + 1 = 2")
>       void addsTwoNumbers() {
> +             fail("failing an 'external' test");
>               Calculator calculator = new Calculator();
>               assertEquals(2, calculator.add(1, 1), "1 + 1 should equal 2");
>       }
> {code}
> If I now run {{mvn package}}, I see fail from the test which was supposed to 
> be skipped.
> If I uncomment the commented out lines in the XML, I get the below warning, 
> but the test I meant to skip is correctly skipped, and the test run passes.
> {noformat}
>  
> +-------------------------------------------------------------------------------+
>  | WARNING:                                                                   
>    |
>  | The junit-platform-surefire-provider has been deprecated and is scheduled 
> to  |
> {noformat}



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

Reply via email to