| commit | 145e0c1b8f2764540400fe75597a40a8941abf9c | [log] [tgz] |
|---|---|---|
| author | Niek Haarman <haarman.niek@gmail.com> | Fri Jul 05 15:27:49 2019 +0200 |
| committer | Niek Haarman <haarman.niek@gmail.com> | Fri Jul 05 15:35:43 2019 +0200 |
| tree | 9621540864551252019004a1bfab8cd54e644e07 | |
| parent | 5c51a89bd5a3c8c067cc84f10a2e9363d3930269 [diff] |
Manually provide values for primitive types On the JVM, primitive types get unboxed automatically, leading to NPE's when the null quirk is used.
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:
testImplementation "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.