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?

3
  • Related to ... stackoverflow.com/questions/45508263/…? Commented Feb 9, 2018 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. Commented Feb 9, 2018 at 15:01
  • 1
    Native Gradle support is almost here. The current plan is to include it in Gradle 4.6 (cf. github.com/gradle/gradle/pull/4116) Commented Feb 10, 2018 at 5:36

1 Answer 1

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' 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.