Skip to content

viniciussoares/mockito-kotlin

 
 

Repository files navigation

Mockito-Kotlin

Download

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

Install

Mockito-Kotlin is available on JCenter. For Gradle users, add the following to your build.gradle:

repositories {
    jcenter()
}
dependencies {
    testCompile "com.nhaarman:mockito-kotlin:x.x.x"
}

Example

A test using Mockito-Kotlin typically looks like the following:

@Test
fun a(){ 
  /* 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.

About

Using Mockito with Kotlin

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 100.0%