5

Using Gradle and its JUnit 4 support, I can choose a specific test using the --tests option like this:

$ ./gradlew test --tests de.mp.BarMT

This option is ineffective when using the JUnit 5 Gradle task. It is ignored silently when using the test tasks from the command line. The true work is done by junitPlatformTest anyway, and it does not support the option:

$ ./gradlew clean junitPlatformTest --tests de.mp.BarMT
…
Problem configuring task :junitPlatformTest from command line.
> Unknown command-line option '--tests'.

Does the JUnit 5 plugin support choosing specific tests?

Michael Piefel
  • 18,660
  • 9
  • 81
  • 112
  • Related to ... https://stackoverflow.com/questions/45508263/single-junit5-test-execution-with-gradle? – glytching Feb 09 '18 at 14:58
  • That’s true. Almost a duplicate, I would say (only that I have real tests, I promise). Weird it did not show up in the search while creating the question. – Michael Piefel Feb 09 '18 at 15:01
  • 1
    Native Gradle support is almost here. The current plan is to include it in Gradle 4.6 (cf. https://github.com/gradle/gradle/pull/4116) – Marc Philipp Feb 10 '18 at 05:36

1 Answers1

3

Answering myself… A lot of time has passed, new versions came, and I can confirm that with Gradle 5.4.1 and JUnit Jupiter Platform 1.4.2, the simple configuration:

test {
    useJUnitPlatform()
}

will allow running single tests as seen in https://stackoverflow.com/a/31468902/2621917, even when using weird names (from Kotlin):

gradle test --tests 'HtmlForwardInterceptorTest.should forward requests'
Michael Piefel
  • 18,660
  • 9
  • 81
  • 112