14
  • Java version java 10.0.1 2018-04-17
  • Kotlin version 1.2.41
  • Gradle version 4.7

it will be even better if we could use jigsaw module system

mkobit
  • 43,979
  • 12
  • 156
  • 150
xiang
  • 1,384
  • 1
  • 12
  • 28

2 Answers2

29

There's documentation and a sample project for using Gradle and JUnit 5.

If you want to use the Kotlin DSL you'll have to adapt it in the following way:

tasks.withType<Test>().configureEach {
    useJUnitPlatform()
}

For Jigsaw, Gradle provides experimental support and there's a fork of the plugin that provides additional features.

Marc Philipp
  • 1,848
  • 12
  • 25
  • Thank you very much. Is there any doc about `tasks.withType`? – xiang May 14 '18 at 11:39
  • Documentation for the Kotlin DSL is in progress and will be ready for the 1.0 release. Currently, your best bet is to look for existing projects that use it and check out the sample projects: https://github.com/gradle/kotlin-dsl/tree/master/samples – Marc Philipp May 14 '18 at 13:22
4

Marc Philipp's answer works. Here is another approach:

val test: Test by tasks
test.useJUnitPlatform()
ordonezalex
  • 2,645
  • 1
  • 20
  • 33