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

No tests executed with junit-platform-suite and -Dtest=TestSuite

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.0-M5
    • 3.0.0-M6
    • JUnit 5.x support
    • None

    Description

      My organization is in the process of moving their SpringBoot Maven builds from JUnit 4 to JUnit 5.  Our "default" build runs all the unit tests.  We also have "component tests" and "integration tests" that are specified in a "TestSuite" class.  The build process specifies the name of the suite class on the command line with "-Dtest=ComponentTestSuite", for instance.  Before the move to JUnit 5, this all worked fine.

      In the move to JUnit 5, I modified ComponentTestSuite to be like this:

          import org.junit.platform.suite.api.SelectClasses;
          import org.junit.platform.suite.api.Suite;

          @Suite
          @SelectClasses(NoteResourceCT.class)
          public class ComponentTestSuite

      {     }

      Now, when I run "mvn -Dtest=ComponentTestSuite test", it says the following:

          [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test) on project ...: No tests were executed!  (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1] 

      There are no other messages.

      My pom.xml basically looks like this:

          <?xml version="1.0" encoding="UTF-8"?>
          <project
          ...
              <dependencyManagement>
                  <dependencies>
                      <dependency>
                          <groupId>org.junit</groupId>
                          <artifactId>junit-bom</artifactId>
                          <version>5.8.2</version>
                          <type>pom</type>
                          <scope>import</scope>
                      </dependency>
                  </dependencies>
              </dependencyManagement>
              <dependencies>
                  <dependency>
                      <groupId>org.springframework.boot</groupId>
                      <artifactId>spring-boot-starter-test</artifactId>
                      <scope>test</scope>          
                  </dependency>
                  <dependency>
                      <groupId>org.mockito</groupId>
                      <artifactId>mockito-junit-jupiter</artifactId>
                      <version>4.4.0</version>
                      <scope>test</scope>
                  </dependency>
                  <dependency>
                      <groupId>junit</groupId>
                      <artifactId>junit</artifactId>
                      <version>4.13.2</version>
                      <scope>test</scope>
                  </dependency>
                  <dependency>
                      <groupId>org.junit.platform</groupId>
                      <artifactId>junit-platform-suite-api</artifactId>
                  </dependency>
                  ...
              </dependencies>
              <build>
                  <plugins>
                      ...
                      <plugin>
                          <artifactId>maven-surefire-plugin</artifactId>
                          <version>3.0.0-M5</version>
                          <configuration>
                              <reuseForks>false</reuseForks>
                              <redirectTestOutputToFile>true</redirectTestOutputToFile>
                          </configuration>
                      </plugin>
                      ...
                  </plugins>
              </build>
          </project>

      Attachments

        Issue Links

          Activity

            People

              tibordigana Tibor Digana
              dkarr David M. Karr
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: