commit | fe18cc645a1b8b8f09ef54f0989b2da3fa3ed1b8 | [log] [tgz] |
---|---|---|
author | Niek Haarman <haarman.niek@gmail.com> | Thu Jun 21 14:32:47 2018 +0200 |
committer | Niek Haarman <haarman.niek@gmail.com> | Thu Jun 21 14:36:14 2018 +0200 |
tree | 79828f93bb761ce4466bd290c0aabf946918d365 | |
parent | f5bc4426c3225a04737dfdd225c0de39e56fed31 [diff] |
Include test to show how to mock a spy invocation with any()
A small library that provides helper functions to work with Mockito in Kotlin.
Mockito-Kotlin is available on Maven Central and JCenter. For Gradle users, add the following to your build.gradle
, replacing x.x.x
with the latest version:
testCompile "com.nhaarman.mockitokotlin2:mockito-kotlin:x.x.x"
A test using Mockito-Kotlin typically looks like the following:
@Test fun doAction_doesSomething(){ /* Given */ val mock = mock<MyClass> { on { getText() } doReturn "text" } val classUnderTest = ClassUnderTest(mock) /* When */ classUnderTest.doAction() /* Then */ verify(mock).doSomething(any()) }
For more info and samples, see the Wiki.