diff --git a/buildSrc/src/main/kotlin/embrace-defaults.gradle.kts b/buildSrc/src/main/kotlin/embrace-defaults.gradle.kts index 2e0144028f..e02397002d 100644 --- a/buildSrc/src/main/kotlin/embrace-defaults.gradle.kts +++ b/buildSrc/src/main/kotlin/embrace-defaults.gradle.kts @@ -17,6 +17,9 @@ plugins { } android { + useLibrary("android.test.runner") + useLibrary("android.test.base") + useLibrary("android.test.mock") compileSdk = Versions.COMPILE_SDK defaultConfig { @@ -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 { diff --git a/buildSrc/src/main/kotlin/io/embrace/gradle/Versions.kt b/buildSrc/src/main/kotlin/io/embrace/gradle/Versions.kt index 30e012af15..fa0721268f 100644 --- a/buildSrc/src/main/kotlin/io/embrace/gradle/Versions.kt +++ b/buildSrc/src/main/kotlin/io/embrace/gradle/Versions.kt @@ -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" } diff --git a/embrace-android-compose/build.gradle.kts b/embrace-android-compose/build.gradle.kts index c9f5926083..694135aa1b 100644 --- a/embrace-android-compose/build.gradle.kts +++ b/embrace-android-compose/build.gradle.kts @@ -13,4 +13,5 @@ dependencies { implementation(libs.lifecycle.extensions) compileOnly(libs.compose) compileOnly(project(":embrace-android-sdk")) + testImplementation(project(":embrace-android-sdk")) } \ No newline at end of file diff --git a/embrace-android-fcm/build.gradle.kts b/embrace-android-fcm/build.gradle.kts index 918d06f498..5eac9f36c9 100644 --- a/embrace-android-fcm/build.gradle.kts +++ b/embrace-android-fcm/build.gradle.kts @@ -11,4 +11,5 @@ android { dependencies { compileOnly(libs.firebase.messaging) compileOnly(project(":embrace-android-sdk")) + testImplementation(project(":embrace-android-sdk")) } diff --git a/embrace-android-okhttp3/build.gradle.kts b/embrace-android-okhttp3/build.gradle.kts index 083edeea68..0f2259c7c3 100644 --- a/embrace-android-okhttp3/build.gradle.kts +++ b/embrace-android-okhttp3/build.gradle.kts @@ -12,6 +12,4 @@ dependencies { compileOnly(libs.okhttp) compileOnly(project(":embrace-android-sdk")) testImplementation(project(":embrace-android-sdk")) - testImplementation(libs.mockk) - testImplementation(libs.mockwebserver) } diff --git a/embrace-android-sdk/build.gradle.kts b/embrace-android-sdk/build.gradle.kts index 70a94802af..a1ce74404b 100644 --- a/embrace-android-sdk/build.gradle.kts +++ b/embrace-android-sdk/build.gradle.kts @@ -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 { @@ -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 } @@ -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().configureEach {