Skip to content

Instantly share code, notes, and snippets.

@mannodermaus
Last active January 28, 2018 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mannodermaus/7b8f9522da6008572193cd86097a855f to your computer and use it in GitHub Desktop.
Save mannodermaus/7b8f9522da6008572193cd86097a855f to your computer and use it in GitHub Desktop.
Using android-junit5 with gradle/kotlin-dsl. https://github.com/mannodermaus/android-junit5
import de.mannodermaus.gradle.plugins.junit5.*
import org.junit.platform.console.options.Details
plugins {
// 1. Declare plugin
id("de.mannodermaus.android-junit5") version "1.0.30"
// More plugins here (Kotlin, Android)
}
android {
testOptions {
// 2. Access DSL (example)
junitPlatform.apply {
details = Details.TREE
}
}
}
dependencies {
// 3. Declare dependencies
// For some odd reason, Kotlin's dependency handler doesn't allow
// to add lists of dependencies using DependencyHandler#add().
// Therefore, iterate over the custom handler's dependency groups & add them one by one instead.
val junit5 = dependencies.ext["junit5"] as JUnit5DependencyHandler
junit5.unitTests().forEach { testCompile(it) }
junit5.parameterized().forEach { testCompile(it) }
}
repositories {
jcenter()
google()
}
pluginManagement {
repositories {
gradlePluginPortal()
google()
}
resolutionStrategy {
eachPlugin {
// 4. Manually map plugin coordinates
if (requested.id.id == "de.mannodermaus.android-junit5") {
useModule("de.mannodermaus.gradle.plugins:android-junit5:${requested.version}")
}
}
}
}
rootProject.buildFileName = "build.gradle.kts"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment