mockito / mockito-kotlin

Using Mockito with Kotlin
MIT License
3.09k stars 198 forks source link

Transitive dependency on objenesis:3.1 causing Android instrumentation tests to fail #433

Closed Amokrane closed 3 years ago

Amokrane commented 3 years ago

Hello,

I would like to share an issue we found when we upgraded to mockito-kotlin:3.1.0:

> Could not resolve all files for configuration ':app:detachedConfiguration4'.
   > Failed to transform jetified-objenesis-3.1.jar to match attributes ***artifactType=ext-dex-dexBuilderStagingAndroidTest, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime***.
      > Execution failed for DexingExternalLibArtifactTransform: /home/runner/.gradle/caches/transforms-3/e98713f6f21d16df260ea582e1a3a736/transformed/jetified-objenesis-3.1.jar.
         > Error while dexing.

After reading https://github.com/mockito/mockito/issues/2007, we found out that this issue is caued by early objenesis:3.x versions, and fixed in objenesis:3.2. Unfortunately, mockito-kotlin depends on mockito-core:3.8.0 which brings in the objenesis:3.1 version. As a workaround, we forced objenesis:3.2 version.

Depending on mockito-core:3.9.0 should fix this issue. I have ran the tests locally with this update and they were successful. I can make a PR if you want.

Thank you.

TimvdLippe commented 3 years ago

Yes please open a PR. Thanks!