Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use JUnit 5 with build.gradle.kts and kotlin?

  • 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

like image 898
xiang Avatar asked May 14 '18 06:05

xiang


2 Answers

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.

like image 79
Marc Philipp Avatar answered Sep 21 '22 17:09

Marc Philipp


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

val test: Test by tasks
test.useJUnitPlatform()
like image 26
ordonezalex Avatar answered Sep 22 '22 17:09

ordonezalex