Created
February 15, 2019 19:54
-
-
Save jeffypooo/ed983365a965ee186e5f04157d0d4861 to your computer and use it in GitHub Desktop.
mockito_kotlin verfiy extensions (similar to stub)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.mockito.verification.VerificationMode | |
| inline fun <T : Any> T.verify(verification: KVerification<T>.(T) -> Unit) = this.apply { | |
| KVerification(this).verification(this) | |
| } | |
| class KVerification<out T>(private val mock: T) { | |
| fun <R> invoked(mode: VerificationMode? = null, methodCall: T.() -> R): R { | |
| return if (null != mode) { | |
| com.nhaarman.mockito_kotlin.verify(mock, mode).methodCall() | |
| } else { | |
| com.nhaarman.mockito_kotlin.verify(mock).methodCall() | |
| } | |
| } | |
| fun noMoreInteractions() = com.nhaarman.mockito_kotlin.verifyNoMoreInteractions(mock) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment