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
Cannot mock sealed class
or sealed interface
with AGP 8.1.0
#3086
Comments
Ok, I got a chance to dig into the code and found this function:
That is explained here: #2392 I debugged I also understand that it is no go add an additional support in I'll try to take a look what can be done on But I still think that this should be possible to mock sealed class at least for Kotlin. Leaving this issue opened for now in case if somebody wants to get answers or help contributing into this problem. |
Same issue here:
|
Mockito cannot mock this class: interface
deps
args
|
Another example w/ Java17 (worked fine w/ Java11):
when attempting to do something like: Using latest versions of Mockito 5.10.0 BOM on Android. |
I am also facing the same issue. Is there any update on this? |
Hello,
After update to AGP 8.1 and JKD 17 I cannot mock sealed classes or sealed interfaces. It works only if subclass is defined. But this is not a solution, since the project is huge and it leads to big number of changes. Also, it adds a confusion why certain subclass is mocked. So, it is better to have a mocked sealed class/interface instead.
Stacktrace:
Example code:
It happens whenever you mock SomeItem sealed class.
As you can see, I tried to play around with different ByteBuddy versions. Also, same behavior applies to older Mockito versions, i.e 4.11.0
It seems like this issue is related: #2975
check that
Note that some configuration are impossible to mock via Mockito
(same as any question on stackoverflow.com)
The text was updated successfully, but these errors were encountered: