Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instrumented test coverage fails with coroutines 1.10.0+ #4340

Open
Del-S opened this issue Jan 23, 2025 · 5 comments
Open

Instrumented test coverage fails with coroutines 1.10.0+ #4340

Del-S opened this issue Jan 23, 2025 · 5 comments
Labels

Comments

@Del-S
Copy link

Del-S commented Jan 23, 2025

Issue: Cannot run instrumented tests when enableAndroidTestCoverage is set to true while using coroutines 1.10.0+. I tried 1.9.0 and it works fine.

* What went wrong:
Execution failed for task ':codebase:domain:mergeExtDexDevDebugAndroidTest'.
> Could not resolve all files for configuration ':codebase:domain:devDebugAndroidTestRuntimeClasspath'.
   > Failed to transform kotlinx-coroutines-debug-1.10.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-debug:1.10.1) to match attributes {artifactType=android-dex, dexing-component-attributes=ComponentSpecificParameters(minSdkVersion=24, debuggable=true, enableCoreLibraryDesugaring=true, enableGlobalSynthetics=true, enableApiModeling=false, dependenciesClassesAreInstrumented=false, asmTransformComponent=null, useJacocoTransformInstrumentation=true, enableDesugaring=true, needsClasspath=false, useFullClasspath=false, componentIfUsingFullClasspath=null), org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for JacocoTransform: /home/david/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-debug/1.10.1/894ec9b16eb3bb3b39037afb7eb7c86e746f5844/kotlinx-coroutines-debug-1.10.1.jar.
         > Unable to instrument file with Jacoco: /home/david/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-debug/1.10.1/894ec9b16eb3bb3b39037afb7eb7c86e746f5844/kotlinx-coroutines-debug-1.10.1.jar

So for now I just want to check coverage while writing tests but we might need to have coverage report combined for unit tests and instrumented tests. I will try to provide some example project during the weekend (I hope), but if anyone has an idea why this happens in the meantime I would appreciate help with this. Thanks.

@Del-S Del-S added the bug label Jan 23, 2025
@dkhalanskyjb dkhalanskyjb added question and removed bug labels Jan 23, 2025
@dkhalanskyjb
Copy link
Collaborator

Looks like your code coverage tool attempts to also check how well your tests cover the code in kotlinx.coroutines. It's worth a try to exclude kotlinx.coroutines code from your coverage check. I don't know how to do that, though; maybe you could ask on Stack Overflow or in Kotlin Slack. Or maybe Android or Jacoco teams could shed some light on this.

@Del-S
Copy link
Author

Del-S commented Jan 23, 2025

Thanks I will take a look at it tomorrow. But the weird thing is that only thing I did is to enable the coverage and I believe it uses embedded Jacoco from AGP or something like that. Also coverage for unit tests works fine. It also starts working if I downgrade coroutines library which I have no idea why. 🤔 But thanks anyway.

@Del-S
Copy link
Author

Del-S commented Feb 6, 2025

Hmm so now the same happens with Paparazzi tests:

Execution failed for task ':codebase:presentation:profile:testDevDebugUnitTest'.
> Could not resolve all files for configuration ':codebase:presentation:profile:devDebugUnitTestRuntimeClasspath'.
   > Failed to transform kotlinx-coroutines-debug-1.10.1.jar (org.jetbrains.kotlinx:kotlinx-coroutines-debug:1.10.1) to match attributes {artifactType=android-asm-instrumented-jars, asm-transformed-variant=devDebugUnitTest, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.environment=standard-jvm, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=jvm}.
      > Execution failed for AsmClassesTransform: /home/david/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-debug/1.10.1/894ec9b16eb3bb3b39037afb7eb7c86e746f5844/kotlinx-coroutines-debug-1.10.1.jar.
         > duplicate entry: META-INF/versions/9/module-info.class

@Del-S
Copy link
Author

Del-S commented Feb 6, 2025

So I just checked the jar files for kotlin-coroutines-debug and 1.9.0 has only one module-info.class inside

Image

But 1.10.1 (same with 1.10.0) has two:

Image

@dkhalanskyjb
Copy link
Collaborator

If that's the issue, it will be fixed in the next release by #4314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants