Last active
January 28, 2018 02:14
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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