Skip to content

Instantly share code, notes, and snippets.

@vbsteven
Last active March 8, 2020 17:18
Show Gist options
  • Save vbsteven/32f741fba8be4d8de5a38bfb526cd7b3 to your computer and use it in GitHub Desktop.
Save vbsteven/32f741fba8be4d8de5a38bfb526cd7b3 to your computer and use it in GitHub Desktop.
Minimal Gradle Kotlin DSL for Junit5 project
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
val kotlinVersion = "1.3.21"
kotlin("jvm") version kotlinVersion
java // required by JUnit
}
group = "io.quantus"
version = "1.0-SNAPSHOT"
val junitPlatformVersion = "5.4.1"
repositories {
mavenCentral()
}
dependencies {
compile(kotlin("reflect"))
compile(kotlin("test"))
compile(kotlin("test-junit"))
compile(kotlin("stdlib-jdk8"))
// JUnit 5
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitPlatformVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitPlatformVersion")
testRuntime("org.junit.platform:junit-platform-console:1.2.0")
}
tasks.withType<Test> {
useJUnitPlatform()
// make sure test results are printed to console
testLogging {
events("passed", "skipped", "failed")
}
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment