You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Dmitry Timofeev (Jira)" <ji...@apache.org> on 2019/11/15 15:59:00 UTC

[jira] [Updated] (SUREFIRE-1720) JUnit 5 @Nested classes are not excluded when name ends in Tests

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

Dmitry Timofeev updated SUREFIRE-1720:
--------------------------------------
    Description: 
{color:#808080}`<exclude>` {color}over source file names does not exclude the {color:#808080}`@Nested` {color}test classes, defined inside the matching source files, if they end with {color:#808080}`Tests`{color}.
h3. Minimal reproducing project

[https://github.com/dmitry-timofeev/surefire-bug] (contains the instrutctions to run)

See AppIntegrationTest.
h3. Surefire Configuration
{code:java}
<plugin>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>${surefire.version}</version>
  <configuration>
    <excludes>
      <!-- (1) Such syntax operates on source file names, according to the docs:
           https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html
           but does not exclude the JUnit 5 @Nested classes, defined in *matching* files. -->
      <exclude>**/*IntegrationTest.java</exclude>
<!--              (2) Regex-syntax operates on classes, according to the docs;
           and excludes the @Nested classes properly: -->
<!--              <exclude>%regex[.*IntegrationTest\$.*]</exclude>-->
    </excludes>
  </configuration>
</plugin>
{code}
h3. {color:#9876aa}Expected Behaviour{color}

When a pattern over source file names is used ({color:#808080}`<exclude>*Pattern.java<exclude>`{color}),
 it must apply to all classes inside that file (including @Nested with any name).
h3. {color:#9876aa}Actual Behaviour{color}

The exclusion does not apply to some @Nested classes inside the matching source file (e.g, ending with {color:#808080}`Tests`{color}).
h3. Workaround

Also add a pattern, operating on _classes:_ {{<exclude>%regex[.*IntegrationTest\$.*]<exclude>}}

  was:
{color:#808080}`<exclude>` {color}over source file names does not exclude the {color:#808080}`@Nested` {color}test classes, defined inside the matching source files, if they end with {color:#808080}`Tests`{color}.
h3. Minimal reproducing project

[https://github.com/dmitry-timofeev/surefire-bug] (contains the instrutctions to run)

See AppIntegrationTest.
h3. Surefire Configuration
{code:java}
<plugin>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>${surefire.version}</version>
  <configuration>
    <excludes>
      <!-- (1) Such syntax operates on source file names, according to the docs:
           https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html
           but does not exclude the JUnit 5 @Nested classes, defined in *matching* files. -->
      <exclude>**/*IntegrationTest.java</exclude>
<!--              (2) Regex-syntax operates on classes, according to the docs;
           and excludes the @Nested classes properly: -->
<!--              <exclude>%regex[.*IntegrationTest\$.*]</exclude>-->
    </excludes>
  </configuration>
</plugin>
{code}
h3. {color:#9876aa}Expected Behaviour{color}

When a pattern over source file names is used ({color:#808080}`<exclude>*Pattern.java<exclude>`{color}),
it must apply to all classes inside that file (including @Nested with any name).
h3. {color:#9876aa}Actual Behaviour{color}

The exclusion does not apply to some @Nested classes inside the matching source file (e.g, ending with {color:#808080}`Tests`{color}).


> JUnit 5 @Nested classes are not excluded when name ends in Tests
> ----------------------------------------------------------------
>
>                 Key: SUREFIRE-1720
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1720
>             Project: Maven Surefire
>          Issue Type: Bug
>    Affects Versions: 2.22.2, 3.0.0-M3
>            Reporter: Dmitry Timofeev
>            Priority: Minor
>
> {color:#808080}`<exclude>` {color}over source file names does not exclude the {color:#808080}`@Nested` {color}test classes, defined inside the matching source files, if they end with {color:#808080}`Tests`{color}.
> h3. Minimal reproducing project
> [https://github.com/dmitry-timofeev/surefire-bug] (contains the instrutctions to run)
> See AppIntegrationTest.
> h3. Surefire Configuration
> {code:java}
> <plugin>
>   <artifactId>maven-surefire-plugin</artifactId>
>   <version>${surefire.version}</version>
>   <configuration>
>     <excludes>
>       <!-- (1) Such syntax operates on source file names, according to the docs:
>            https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html
>            but does not exclude the JUnit 5 @Nested classes, defined in *matching* files. -->
>       <exclude>**/*IntegrationTest.java</exclude>
> <!--              (2) Regex-syntax operates on classes, according to the docs;
>            and excludes the @Nested classes properly: -->
> <!--              <exclude>%regex[.*IntegrationTest\$.*]</exclude>-->
>     </excludes>
>   </configuration>
> </plugin>
> {code}
> h3. {color:#9876aa}Expected Behaviour{color}
> When a pattern over source file names is used ({color:#808080}`<exclude>*Pattern.java<exclude>`{color}),
>  it must apply to all classes inside that file (including @Nested with any name).
> h3. {color:#9876aa}Actual Behaviour{color}
> The exclusion does not apply to some @Nested classes inside the matching source file (e.g, ending with {color:#808080}`Tests`{color}).
> h3. Workaround
> Also add a pattern, operating on _classes:_ {{<exclude>%regex[.*IntegrationTest\$.*]<exclude>}}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)