Make `same` return non-null type
2 files changed
tree: a4925fdb707433726467f298065790cf1ce09f7d
  1. .github/
  2. gradle/
  3. mockito-kotlin/
  4. .gitignore
  5. .travis.yml
  6. build.gradle
  7. gradle.properties
  8. gradlew
  9. gradlew.bat
  10. LICENSE
  11. README.md
  12. RELEASING.md
  13. settings.gradle
README.md

Mockito-Kotlin

Download

A small library that provides helper functions to work with Mockito in Kotlin.

Install

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:mockito-kotlin:x.x.x"

Example

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.