Skip to content

[SUREFIRE-2040] No tests executed with junit-platform-suite and -Dtest=TestSuite #2604

@jira-importer

Description

@jira-importer

David M. Karr opened SUREFIRE-2040 and commented

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>


Affects: 3.0.0-M5

Remote Links:

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpriority:majorMajor loss of function

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions