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

Cannot combine in-/excludes with '-DTest'

    XMLWordPrintableJSON

Details

    Description

      Something that works in Surefire 2.22.2 does not work in 3.0.0-M5 and 3.0.0-M6-SNAPSHOT anymore: the combination of in-/excludes with `-Dtest=MyTest`. My situation is as follows:

      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <!--
          Configure two executions:
            - default-test for JUnit 5 (incl. Spock)
            - testng-test for TestNG (incl. JUnit 4)
          See https://issues.apache.org/jira/browse/SUREFIRE-377?focusedCommentId=14456950&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14456950
        -->
        <executions>
          <execution>
            <id>default-test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <testNGArtifactName>none:none</testNGArtifactName>
              <excludes>
                <exclude>**/*TestNG*</exclude>
                <exclude>**/*JUnit4*</exclude>
              </excludes>
            </configuration>
          </execution>
          <execution>
            <id>testng-test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <junitArtifactName>none:none</junitArtifactName>
              <includes>
                <include>**/*TestNG*</include>
                <include>**/*JUnit4*</include>
              </includes>
            </configuration>
          </execution>
        </executions>
      </plugin>
      

      The result when running mvn test -Dtest=MyTest is that both executions execute that test, even though in the second one it is not part of the include patterns. In 2.22.2 this works as expected.

      Attachments

        Activity

          People

            Unassigned Unassigned
            kriegaex Alexander Kriegisch
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: