Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-1720

JUnit 5 @Nested classes are not excluded when name ends in Tests

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.22.2, 3.0.0-M3
    • None
    • None
    • None

    Description

      `<exclude>` over source file names does not exclude the `@Nested` test classes, defined inside the matching source files, if they end with `Tests`.

      Minimal reproducing project

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

      See AppIntegrationTest.

      Surefire Configuration

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

      Expected Behaviour

      When a pattern over source file names is used (`<exclude>*Pattern.java<exclude>`),
      it must apply to all classes inside that file (including @Nested with any name).

      Actual Behaviour

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

      Workaround

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

      Attachments

        Activity

          People

            Unassigned Unassigned
            dt Dmitry Timofeev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: