From 483a7549fa317817cf813d2e6a6249b250a5d94b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 14 Oct 2023 23:24:34 +0200 Subject: [PATCH] test-dependecies -> kts --- build.gradle.kts | 1 + buildSrc/src/main/kotlin/Libs.kt | 31 +++++++++-- .../main/kotlin/test-dependencies.gradle.kts | 53 +++++++++++++++++++ core/interfaces/build.gradle.kts | 2 +- 4 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 buildSrc/src/main/kotlin/test-dependencies.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts index fc3d29062d..fc4adaefeb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -88,6 +88,7 @@ allprojects { kotlinOptions { freeCompilerArgs = listOf( "-opt-in=kotlin.RequiresOptIn", + "-opt-in=kotlin.ExperimentalUnsignedTypes", "-Xjvm-default=all" //Support @JvmDefault ) jvmTarget = "11" diff --git a/buildSrc/src/main/kotlin/Libs.kt b/buildSrc/src/main/kotlin/Libs.kt index 1980828178..20830f53dc 100644 --- a/buildSrc/src/main/kotlin/Libs.kt +++ b/buildSrc/src/main/kotlin/Libs.kt @@ -5,6 +5,7 @@ object Libs { const val kotlin = "1.9.10" + const val test = "org.jetbrains.kotlin:kotlin-test:$kotlin" } object KotlinX { @@ -21,6 +22,14 @@ object Libs { const val appCompat = "androidx.appcompat:appcompat:1.6.1" const val preference = "androidx.preference:preference-ktx:1.2.1" const val workRuntimeKtx = "androidx.work:work-runtime-ktx:2.8.1" + + object Test { + + const val espressoCore = "androidx.test.espresso:espresso-core:3.5.1" + const val extKtx = "androidx.test.ext:junit-ktx:1.1.5" + const val rules = "androidx.test:rules:1.5.0" + const val uiAutomator = "androidx.test.uiautomator:uiautomator:2.2.0" + } } object Google { @@ -28,6 +37,8 @@ object Libs { const val measurementApi = "com.google.android.gms:play-services-measurement-api:21.3.0" } + + const val truth = "com.google.truth:truth:1.1.5" } object Dagger { @@ -59,8 +70,24 @@ object Libs { const val logbackAndroid = "com.github.tony19:logback-android:2.0.0" } - const val joda = "net.danlew:android.joda:2.12.5" + object JUnit { + + private const val junitVersion = "5.10.0" + + const val jupiter = "org.junit.jupiter:junit-jupiter:$junitVersion" + const val jupiterApi = "org.junit.jupiter:junit-jupiter-api:$junitVersion" + } + + object Mockito { + + const val jupiter = "org.mockito:mockito-junit-jupiter:5.6.0" + const val kotlin = "org.mockito.kotlin:mockito-kotlin:5.1.0" + } + const val androidSvg = "com.caverock:androidsvg:1.4" + const val joda = "net.danlew:android.joda:2.12.5" + const val json = "org.json:json:20230618" + const val jsonAssert = "org.skyscreamer:jsonassert:1.5.0" const val room = "2.5.2" const val lifecycle = "2.6.2" @@ -79,11 +106,9 @@ object Libs { const val guava = "32.1.3-jre" const val work = "2.8.1" const val tink = "1.10.0" - const val json = "20230618" const val swipe = "1.1.0" const val junit = "4.13.2" - const val junit_jupiter = "5.10.0" const val mockito = "5.6.0" const val dexmaker = "1.2" const val retrofit2 = "2.9.0" diff --git a/buildSrc/src/main/kotlin/test-dependencies.gradle.kts b/buildSrc/src/main/kotlin/test-dependencies.gradle.kts new file mode 100644 index 0000000000..78272f8852 --- /dev/null +++ b/buildSrc/src/main/kotlin/test-dependencies.gradle.kts @@ -0,0 +1,53 @@ +import org.gradle.api.tasks.testing.logging.TestExceptionFormat +import org.gradle.api.tasks.testing.logging.TestLogEvent + +plugins { + id("com.android.library") + id("kotlin-android") +} + +dependencies { + testImplementation(Libs.Kotlin.test) + testImplementation(Libs.JUnit.jupiter) + testImplementation(Libs.JUnit.jupiterApi) + testImplementation(Libs.json) + testImplementation(Libs.Mockito.jupiter) + testImplementation(Libs.Mockito.kotlin) + testImplementation(Libs.joda) + testImplementation(Libs.Google.truth) + testImplementation(Libs.jsonAssert) + + androidTestImplementation(Libs.AndroidX.Test.espressoCore) + androidTestImplementation(Libs.AndroidX.Test.extKtx) + androidTestImplementation(Libs.AndroidX.Test.rules) + //androidTestImplementation(Libs.AndroidX.Test.uiAutomator) +} + +tasks.withType { + // use to display stdout in travis + testLogging { + // set options for log level LIFECYCLE + events = setOf( + TestLogEvent.FAILED, + TestLogEvent.STARTED, + TestLogEvent.SKIPPED, + TestLogEvent.STANDARD_OUT + ) + exceptionFormat = TestExceptionFormat.FULL + useJUnitPlatform() + } +} + +tasks.withType().configureEach { + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) + forkEvery = 20 +} + +android { + testOptions { + unitTests { + isReturnDefaultValues = true + isIncludeAndroidResources = true + } + } +} diff --git a/core/interfaces/build.gradle.kts b/core/interfaces/build.gradle.kts index 5efa25c7de..23340e5179 100644 --- a/core/interfaces/build.gradle.kts +++ b/core/interfaces/build.gradle.kts @@ -7,9 +7,9 @@ plugins { id("kotlinx-serialization") id("android-module-dependencies") id("all-open-dependencies") + id("test-dependencies") } -apply(from = "${project.rootDir}/core/main/test_dependencies.gradle") apply(from = "${project.rootDir}/core/main/jacoco_global.gradle") android {