Verify Extension Function / kotlin
See original GitHub issue@RunWith(MockitoJUnitRunner::class)
internal class HighOrderTest {
@Mock
lateinit var a: A
@Test
fun test() {
// When
a.run()
// Then
verify(a).doSomething()
}
}
open class A
fun A.run() {
doSomething()
}
fun A.doSomething() {
}
The above test will fail with:
org.mockito.exceptions.misusing.UnfinishedVerificationException:
Missing method call for verify(mock) here:
I guess it’s not possible yet to verify the high order doSomething
. Is it possible to implement this feature? If not a explicit error would be helpful I think
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How should I test Kotlin extension functions? - Stack Overflow
1 Answer 1 ... Well, to test a method, whether static or not, you call it as real code would do, and you...
Read more >Testing Kotlin extension functions | www.rolfje.com
This test will not only run your extension function, but you can even verify that the extension function calls the correct functions on...
Read more >Mockk- Testing Extension Functions | by Byte Sized Bits
Extension functions can be useful to extend an existing library easily. Testing can be sometimes a bit challenging.
Read more >Extensions | Kotlin
This mechanism is called an extension function. There are also extension properties that let you define new properties for existing classes.
Read more >Testing Kotlin extension functions | Rolfje's blog
This test will not only run your extension function, but you can even verify that the extension function calls the correct functions on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
those are extension functions dudes, not high-order functions.
anyway, this works for me.
are you using mockito-kotlin?