-
Notifications
You must be signed in to change notification settings - Fork 197
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
how to verify a static method in kotlin #457
Comments
@lannyf77 : Were you able to figure out a solution for this? |
@aakash1313 @lannyf77 Basically look at the decompiled kotlin classes. You will see there are more than 1 layer of static functions / classes. Which are really difficult to clear from tests. So either use interface level of abstraction for mocking. |
@lannyf77 In Kotlin lambdas are written like this: theMock.verify({ TestSingleton.staticMethod(any(Context::class.java), "test") }, times(1))
// or
theMock.verify(times(1)) { TestSingleton.staticMethod(any(Context::class.java)) } not the way Java does. In your code you have mix of Java syntax, that's why it's a syntax error. |
Having a kotlin singleton with static methods
In java test code:
it runs fine
but convert to kotlin it does not compile:
having mockito version
testImplementation "org.mockito:mockito-inline:3.12.4"
.How to test/verify static method using mockito in kotlin?
The text was updated successfully, but these errors were encountered: