Skip to content

Commit

Permalink
Merge pull request #1018 from embrace-io/test-standardisation
Browse files Browse the repository at this point in the history
Refactor test build script setup
  • Loading branch information
fractalwrench authored Jul 2, 2024
2 parents 9cf7014 + 248c4de commit 3ed421b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 25 deletions.
20 changes: 19 additions & 1 deletion buildSrc/src/main/kotlin/embrace-defaults.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ plugins {
}

android {
useLibrary("android.test.runner")
useLibrary("android.test.base")
useLibrary("android.test.mock")
compileSdk = Versions.COMPILE_SDK

defaultConfig {
Expand Down Expand Up @@ -71,13 +74,28 @@ android {
withJavadocJar()
}
}

sourceSets {
getByName("test").java.srcDir("src/integrationTest/java")
getByName("test").kotlin.srcDir("src/integrationTest/kotlin")
getByName("test").resources.srcDir("src/integrationTest/resources")
}
}

dependencies {
testImplementation("junit:junit:${Versions.JUNIT}")
implementation("org.jetbrains.kotlin:kotlin-stdlib:${Versions.KOTLIN_EXPOSED}")
add("detektPlugins", "io.gitlab.arturbosch.detekt:detekt-formatting:${Versions.DETEKT}")
add("lintChecks", project.project(":embrace-lint"))

testImplementation("junit:junit:${Versions.JUNIT}")
testImplementation("io.mockk:mockk:${Versions.MOCKK}")
testImplementation("androidx.test:core:${Versions.ANDROIDX_TEST}")
testImplementation("androidx.test.ext:junit:${Versions.ANDROIDX_JUNIT}")
testImplementation("org.robolectric:robolectric:${Versions.ROBOLECTRIC}")
testImplementation("com.squareup.okhttp3:mockwebserver:${Versions.MOCKWEBSERVER}")

androidTestImplementation("androidx.test:core:${Versions.ANDROIDX_TEST}")
androidTestImplementation("androidx.test:runner:${Versions.ANDROIDX_TEST}")
}

checkstyle {
Expand Down
5 changes: 5 additions & 0 deletions buildSrc/src/main/kotlin/io/embrace/gradle/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ object Versions {
const val DETEKT = "1.23.0"

const val NDK = "21.4.7075529"
const val MOCKK = "1.12.2"
const val ANDROIDX_TEST = "1.4.0"
const val ANDROIDX_JUNIT = "1.1.3"
const val ROBOLECTRIC = "4.12.1"
const val MOCKWEBSERVER = "4.9.3"
}
1 change: 1 addition & 0 deletions embrace-android-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ dependencies {
implementation(libs.lifecycle.extensions)
compileOnly(libs.compose)
compileOnly(project(":embrace-android-sdk"))
testImplementation(project(":embrace-android-sdk"))
}
1 change: 1 addition & 0 deletions embrace-android-fcm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ android {
dependencies {
compileOnly(libs.firebase.messaging)
compileOnly(project(":embrace-android-sdk"))
testImplementation(project(":embrace-android-sdk"))
}
2 changes: 0 additions & 2 deletions embrace-android-okhttp3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@ dependencies {
compileOnly(libs.okhttp)
compileOnly(project(":embrace-android-sdk"))
testImplementation(project(":embrace-android-sdk"))
testImplementation(libs.mockk)
testImplementation(libs.mockwebserver)
}
22 changes: 0 additions & 22 deletions embrace-android-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ plugins {
description = "Embrace Android SDK: Core"

android {
useLibrary("android.test.runner")
useLibrary("android.test.base")
useLibrary("android.test.mock")
ndkVersion = Versions.NDK

defaultConfig {
Expand All @@ -36,14 +33,6 @@ android {
packagingOptions {
pickFirst("**/*.so")
}

sourceSets {
// Had to add a 'java' directory to store Java test files, as it doesn't get picked up as a test if I put it in
// the kotlin directory. If I've just screwed up somehow and this is actually possible, please consolidate.
getByName("test").java.srcDir("src/integrationTest/java")
getByName("test").kotlin.srcDir("src/integrationTest/kotlin")
}

buildFeatures {
buildConfig = true
}
Expand Down Expand Up @@ -89,23 +78,12 @@ dependencies {
// Please, don"t update it until we update compileSdk.
implementation(libs.profileinstaller)

testImplementation(libs.mockk)
testImplementation(libs.androidx.test.core)
testImplementation(libs.androidx.test.junit)
testImplementation(libs.robolectric)
testImplementation(project(path = ":embrace-android-sdk"))
testImplementation(libs.mockwebserver)
testImplementation(libs.protobuf.java)
testImplementation(libs.protobuf.java.util)
testImplementation(libs.kotlin.reflect)

dokkaHtmlPlugin(libs.dokka.convert)
dokkaHtmlPlugin(libs.dokka.docs)

// For the functional tests
androidTestImplementation(libs.androidx.test.core)
androidTestImplementation(libs.androidx.test.runner)
androidTestImplementation(project(path = ":embrace-android-sdk"))
}

tasks.withType<DokkaTask>().configureEach {
Expand Down

0 comments on commit 3ed421b

Please sign in to comment.