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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot mocking sealed interface
with AGP 8.0
#2975
Comments
I am also having this issue after trying to upgrade to the latest AGP (8.0.1) and Kotlin (1.8.21). All my tests that involve sealed classes are failing to mock said classes. I tried forcing the latest version of Bytebuddy (1.14.4) as I saw some other similar issues that were able to resolve with various versions of Bytebuddy, but this did not work for me. Any help on this would be appreciated, this is preventing my company from updating to the latest AGP and Kotlin versions. |
I also experience the same issue. Mocking concrete implementation did work for me. See an example below sealed interface Response {
data class Success(data:String): Response
data class Error(message:String): Response
}
val mockedResponse: Response = mock<Response>() // doesn't work
val mockedResponse: Response = mock<Response.Success>() // does work |
We had the same issue but with AGP 7.4.2, so that doesn't seem to be the cause. We did see the issue after updating to Java 17 and Kotlin 1.8. The solution was to use specific versions of the sealed class as described by @MyDogTom 馃憤
|
I have the same problem with springclass HttpStatusCode |
same issue here with kotlin and kgp 1.8, agp and gradle 8 and mockito 4.0.0 |
I'm having the same issue. Is there any workaround for this? |
I am having the same problem. Java : 17 I have tried creating in the classpath a file /mockito-extensions/org.mockito.plugins.MockMaker containing the value mock-maker-inline (as mentioned in the javadoc under item #39) but, unfortunately, that did not help. |
Note: Changing the Java compatibility to 11 fixes the issue. |
Thank you. |
@skaengus2012 It's not true that Now In Android uses 17. It uses 17 for build logic https://github.com/android/nowinandroid/blob/main/build-logic/convention/build.gradle.kts For building Android app and modules it uses Java 11 https://github.com/android/nowinandroid/blob/main/build-logic/convention/src/main/kotlin/com/google/samples/apps/nowinandroid/KotlinAndroid.kt |
Oh thanks, Good to know |
I'm having the same problem.
Kotlin: 1.9.22 |
I saw that we have a glue for this issue: |
After update AGP 8.0, mockito cannot mock
sealed interface
. 馃When
sealed
keyword was removed, mockito worked very well.dependecy
stacktrace
Please check the code of the project below:
The text was updated successfully, but these errors were encountered: