Create module to release a kt1.1 artifact
5 files changed
tree: dab538b005a92f789e7e0b9e99f301c31381589f
  1. .github/
  2. gradle/
  3. mockito-kotlin/
  4. mockito-kotlin-kt1.1/
  5. .gitignore
  6. .travis.yml
  7. build.gradle
  8. gradle.properties
  9. gradlew
  10. gradlew.bat
  11. LICENSE
  12. publishing.gradle
  13. README.md
  14. RELEASING.md
  15. 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"

If you use Kotlin 1.1, you can instead depend on the mockito-kotlin-kt1.1 artifact.

testCompile "com.nhaarman:mockito-kotlin-kt1.1: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.