appfoundry / mockito-kotlin

Using Mockito with Kotlin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Forked from https://github.com/nhaarman/mockito-kotlin. Ported to Mockito 1 to support PowerMock!

Mockito1-Kotlin

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

Example

A test using Mockito1-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())
}

About

Using Mockito with Kotlin

License:MIT License


Languages

Language:Kotlin 100.0%