Merge branch 'checketts-2.x' into 2.x
tree: 3630af139165fe926843e11af2b582876885cbbc
  1. .github/
  2. .idea/
  3. gradle/
  4. mockito-kotlin/
  5. ops/
  6. tests/
  7. .gitignore
  8. .travis.yml
  9. build.gradle
  10. gradle.properties
  11. gradlew
  12. gradlew.bat
  13. LICENSE
  14. publishing.gradle
  15. README.md
  16. RELEASING.md
  17. 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:

testImplementation "com.nhaarman.mockitokotlin2: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.