Gradle: JUnit 5: Allow resource-based testing

Created on 20 Mar 2018  路  3Comments  路  Source: gradle/gradle

JUnit platform tests are not necessarily class-based. Frameworks like cucumber use resource files instead. Right now our Test task only supports scanning classes. To support the full range of JUnit engines, we need to consider how to fit such resource-based tests into our infrastructure.

@jvm feature member testing

Most helpful comment

In the meantime, you can use JUnit's ConsoleLauncher and define a custom task, similar to what the JUnit team does in their documentation project: https://github.com/junit-team/junit5/blob/42226ba17ec1db49a804e2f603ca77dcafee5f40/documentation/documentation.gradle.kts#L60-L73

All 3 comments

@oehme rather then trying to add resource based tests next to class based test I believe the proper solution is to fully use the JUnit engines test discovery functionality.

Currently the JUnitPlatformTestClassProcessor uses ClassSelector to select tests in classes selected/discovered by Gradle. Using a ClasspathRootSelector would allow allow test engines to discover all tests in that class path root, including Cucumber tests.

I've looked at this for a few hours and I concur with marcphilip https://github.com/gradle/gradle/issues/4252#issuecomment-434217496 that this 'would require substantial changes to the whole testing infrastructure'.

In the meantime, you can use JUnit's ConsoleLauncher and define a custom task, similar to what the JUnit team does in their documentation project: https://github.com/junit-team/junit5/blob/42226ba17ec1db49a804e2f603ca77dcafee5f40/documentation/documentation.gradle.kts#L60-L73

That is a good work around.Cheers!

Was this page helpful?
0 / 5 - 0 ratings