JUnit 5 Suite Platform failed to discover tests

Viewed 460

I have a simple poc project to check test suite functionality using Junit 5.

My pom.xml is:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M5</version>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite</artifactId>
            <version>1.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

TestSuite.java class is

@Suite
@SuiteDisplayName("Sample Suite")
@SelectClasses({TestClassOne.class, TestClassTwo.class})
public class TestSuite {

    @BeforeAll
    public static void initMethod() {
        System.out.println("Initiating tests from Suite");
    }
    
    @AfterAll
    public static void tearDown() {
        System.out.println("Completed Testing");
    }
    
    @Test
    public void simpleTest() {
        System.out.println("test method in suite");
    }
}

Running the TestSuite either using mvn test or Run as Junit Test throws an exception

org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-platform-suite' failed to discover tests
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:160)
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverSafely(EngineDiscoveryOrchestrator.java:134)
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:108)
    at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:80)
    at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:110)
    at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:78)

What is wrong in my configuration/code? Any help/pointers to resolve this issue.

Thanks. Happy New Year !!!

0 Answers
Related