diff --git a/.claude/skills/test/SKILL.md b/.claude/skills/test/SKILL.md index bdef12364f3..7e6ddd37294 100644 --- a/.claude/skills/test/SKILL.md +++ b/.claude/skills/test/SKILL.md @@ -40,9 +40,9 @@ Determine the Gradle test task: | Module Pattern | Test Task | |---------------|-----------| -| `sentry-android-*` | `testDebugUnitTest` | -| `sentry-compose*` | `testDebugUnitTest` | -| `*-android` | `testDebugUnitTest` | +| `sentry-android-*` | `testReleaseUnitTest` | +| `sentry-compose*` | `testReleaseUnitTest` | +| `*-android` | `testReleaseUnitTest` | | Everything else | `test` | **Interactive mode:** Before running, read the test class file and use AskUserQuestion to ask: diff --git a/.cursor/rules/coding.mdc b/.cursor/rules/coding.mdc index fbcda27b120..70ac39e43a2 100644 --- a/.cursor/rules/coding.mdc +++ b/.cursor/rules/coding.mdc @@ -24,7 +24,7 @@ sentry-java is the Java and Android SDK for Sentry. This repository contains the ./gradlew check # Run unit tests for a specific file -./gradlew '::testDebugUnitTest' --tests="**" --info +./gradlew '::testReleaseUnitTest' --tests="**" --info ``` ## Contributing Guidelines diff --git a/AGENTS.md b/AGENTS.md index ec2ef62974c..de4e29376ad 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -44,13 +44,13 @@ The project uses **Gradle** with Kotlin DSL. Key build files: ### Testing ```bash # Run unit tests for a specific file -./gradlew '::testDebugUnitTest' --tests="**" --info +./gradlew '::testReleaseUnitTest' --tests="**" --info # Run system tests (requires Python virtual env) make systemTest # Run specific test suites -./gradlew :sentry-android-core:testDebugUnitTest +./gradlew :sentry-android-core:testReleaseUnitTest ./gradlew :sentry:test ``` diff --git a/buildSrc/src/main/java/Config.kt b/buildSrc/src/main/java/Config.kt index 7575670a38a..09d2869988b 100644 --- a/buildSrc/src/main/java/Config.kt +++ b/buildSrc/src/main/java/Config.kt @@ -12,8 +12,10 @@ object Config { object Android { val abiFilters = listOf("x86", "armeabi-v7a", "x86_64", "arm64-v8a") + // Debug variants are disabled everywhere. Unit tests run against the release + // variant, so building the debug variant would only add overhead. fun shouldSkipDebugVariant(name: String?): Boolean { - return System.getenv("CI")?.toBoolean() ?: false && name == "debug" + return name == "debug" } } diff --git a/sentry-android-core/build.gradle.kts b/sentry-android-core/build.gradle.kts index f92876530fd..23248d6dae4 100644 --- a/sentry-android-core/build.gradle.kts +++ b/sentry-android-core/build.gradle.kts @@ -34,8 +34,8 @@ android { getByName("release") { consumerProguardFiles("proguard-rules.pro") } } - // AGP 9 only generates unit tests for the testBuildType. CI disables the debug - // variant, so unit tests must target release to run at all. + // AGP 9 only generates unit tests for the testBuildType. The debug variant is + // disabled, so unit tests must target release to run at all. testBuildType = "release" kotlin { compilerOptions.jvmTarget = JVM_1_8 } @@ -83,7 +83,7 @@ tasks.withType().configureEach { // outputs so Gradle's build cache restores them on cache hits (otherwise the CLI upload step // finds an empty directory). tasks - .matching { it.name == "testDebugUnitTest" || it.name == "testReleaseUnitTest" } + .matching { it.name == "testReleaseUnitTest" } .configureEach { outputs.dir(layout.buildDirectory.dir("test-snapshots")) } dependencies { diff --git a/sentry-android-distribution/build.gradle.kts b/sentry-android-distribution/build.gradle.kts index 363bce003f4..c699c364c3b 100644 --- a/sentry-android-distribution/build.gradle.kts +++ b/sentry-android-distribution/build.gradle.kts @@ -13,8 +13,8 @@ android { defaultConfig { minSdk = libs.versions.minSdk.get().toInt() } buildFeatures { buildConfig = false } - // AGP 9 only generates unit tests for the testBuildType. CI disables the debug - // variant, so unit tests must target release to run at all. + // AGP 9 only generates unit tests for the testBuildType. The debug variant is + // disabled, so unit tests must target release to run at all. testBuildType = "release" testOptions { diff --git a/sentry-android-fragment/build.gradle.kts b/sentry-android-fragment/build.gradle.kts index 197c0b05d6a..3ef1c1934f8 100644 --- a/sentry-android-fragment/build.gradle.kts +++ b/sentry-android-fragment/build.gradle.kts @@ -25,8 +25,8 @@ android { getByName("release") { consumerProguardFiles("proguard-rules.pro") } } - // AGP 9 only generates unit tests for the testBuildType. CI disables the debug - // variant, so unit tests must target release to run at all. + // AGP 9 only generates unit tests for the testBuildType. The debug variant is + // disabled, so unit tests must target release to run at all. testBuildType = "release" kotlin { diff --git a/sentry-android-navigation/build.gradle.kts b/sentry-android-navigation/build.gradle.kts index 5ac9842548f..6c1aa62a57d 100644 --- a/sentry-android-navigation/build.gradle.kts +++ b/sentry-android-navigation/build.gradle.kts @@ -25,8 +25,8 @@ android { getByName("release") { consumerProguardFiles("proguard-rules.pro") } } - // AGP 9 only generates unit tests for the testBuildType. CI disables the debug - // variant, so unit tests must target release to run at all. + // AGP 9 only generates unit tests for the testBuildType. The debug variant is + // disabled, so unit tests must target release to run at all. testBuildType = "release" kotlin { diff --git a/sentry-android-ndk/build.gradle.kts b/sentry-android-ndk/build.gradle.kts index ba651da56ac..6867d964124 100644 --- a/sentry-android-ndk/build.gradle.kts +++ b/sentry-android-ndk/build.gradle.kts @@ -26,8 +26,8 @@ android { getByName("release") { consumerProguardFiles("proguard-rules.pro") } } - // AGP 9 only generates unit tests for the testBuildType. CI disables the debug - // variant, so unit tests must target release to run at all. + // AGP 9 only generates unit tests for the testBuildType. The debug variant is + // disabled, so unit tests must target release to run at all. testBuildType = "release" kotlin { compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8 } diff --git a/sentry-android-replay/build.gradle.kts b/sentry-android-replay/build.gradle.kts index 02f2dab3d4d..45838cb1e1b 100644 --- a/sentry-android-replay/build.gradle.kts +++ b/sentry-android-replay/build.gradle.kts @@ -34,8 +34,8 @@ android { getByName("release") { consumerProguardFiles("proguard-rules.pro") } } - // AGP 9 only generates unit tests for the testBuildType. CI disables the debug - // variant, so unit tests must target release to run at all. + // AGP 9 only generates unit tests for the testBuildType. The debug variant is + // disabled, so unit tests must target release to run at all. testBuildType = "release" kotlin { diff --git a/sentry-android-sqlite/build.gradle.kts b/sentry-android-sqlite/build.gradle.kts index e1e3bc68765..9cf09fd76fd 100644 --- a/sentry-android-sqlite/build.gradle.kts +++ b/sentry-android-sqlite/build.gradle.kts @@ -25,8 +25,8 @@ android { getByName("release") { consumerProguardFiles("proguard-rules.pro") } } - // AGP 9 only generates unit tests for the testBuildType. CI disables the debug - // variant, so unit tests must target release to run at all. + // AGP 9 only generates unit tests for the testBuildType. The debug variant is + // disabled, so unit tests must target release to run at all. testBuildType = "release" kotlin { diff --git a/sentry-android-timber/build.gradle.kts b/sentry-android-timber/build.gradle.kts index e55b8b0e3c5..3c8ac1ea1e4 100644 --- a/sentry-android-timber/build.gradle.kts +++ b/sentry-android-timber/build.gradle.kts @@ -32,8 +32,8 @@ android { getByName("release") { consumerProguardFiles("proguard-rules.pro") } } - // AGP 9 only generates unit tests for the testBuildType. CI disables the debug - // variant, so unit tests must target release to run at all. + // AGP 9 only generates unit tests for the testBuildType. The debug variant is + // disabled, so unit tests must target release to run at all. testBuildType = "release" kotlin { diff --git a/sentry-compose/build.gradle.kts b/sentry-compose/build.gradle.kts index 388bfe832bb..4ebd9349662 100644 --- a/sentry-compose/build.gradle.kts +++ b/sentry-compose/build.gradle.kts @@ -92,8 +92,8 @@ android { getByName("release") { consumerProguardFiles("proguard-rules.pro") } } - // AGP 9 only generates unit tests for the testBuildType. CI disables the debug - // variant, so unit tests must target release to run at all. + // AGP 9 only generates unit tests for the testBuildType. The debug variant is + // disabled, so unit tests must target release to run at all. testBuildType = "release" testOptions { diff --git a/sentry-launchdarkly-android/build.gradle.kts b/sentry-launchdarkly-android/build.gradle.kts index 32b3641203f..f201c57b97d 100644 --- a/sentry-launchdarkly-android/build.gradle.kts +++ b/sentry-launchdarkly-android/build.gradle.kts @@ -27,8 +27,8 @@ android { getByName("release") { consumerProguardFiles("proguard-rules.pro") } } - // AGP 9 only generates unit tests for the testBuildType. CI disables the debug - // variant, so unit tests must target release to run at all. + // AGP 9 only generates unit tests for the testBuildType. The debug variant is + // disabled, so unit tests must target release to run at all. testBuildType = "release" kotlin { compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8 } diff --git a/sentry-samples/sentry-samples-android/build.gradle.kts b/sentry-samples/sentry-samples-android/build.gradle.kts index f994081450d..0cc78a38f77 100644 --- a/sentry-samples/sentry-samples-android/build.gradle.kts +++ b/sentry-samples/sentry-samples-android/build.gradle.kts @@ -133,10 +133,6 @@ android { kotlin { compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11 } - androidComponents.beforeVariants { - it.enable = !Config.Android.shouldSkipDebugVariant(it.buildType) - } - androidComponents.onVariants { variant -> variant.buildConfigFields?.put( "USE_SAGP",