Gradle does not pick up my JUnit Test Suite

I have this JUnit5 test suite.

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

@Suite
@SuiteDisplayName("SimpleTestSuite")
@SelectClasses({SomeTest.class, AnotherTest.class})
public class SimpleTestSuite {
//nothing here
}

I have configured the test class like this.

tasks.named('test', Test).configure {
    useJUnitPlatform {
        include '**/SimpleTestSuite*'
    }
}

This does not run SomeTest.class and AnotherTest.class. But if I add a test case directly to the SimpleTestSuite, it runs that test only. What configuration am I missing here? Or doesn’t gradle support @Suite?

Thanks.

When you do useJUnitPlatform, Gradlew does not support any tests at all. It just kicks off the JUnit Platform which then executes the engines you have added. So add the junit-platform-suite-engine dependency as testRuntimeOnly and it should probably work.

Thanks for the clarification. :bowing_man:

1 Like