Upgrade to Pro — share decks privately, control downloads, hide ads and more …

mockito-kotlin

 mockito-kotlin

Android Test Night #2

Keisuke Kobayashi

December 15, 2017
Tweet

More Decks by Keisuke Kobayashi

Other Decks in Programming

Transcript

  1. About Me • Keisuke Kobayashi • GitHub, QIita: kobakei •

    Twitter: kobakei122 • Kyash, Inc • ݸਓࣄۀओ
  2. Mockito in Java // Java import static org.mockito.Mockito.*; Hoge mock

    = mock(Hoge.class); when(mock.sayHello()).thenReturn("Hello"); when(mock.sayBye()).thenReturn("Bye");
  3. Convert to Kotlin // Kotlin import org.mockito.Mockito.* val mock =

    mock(Hoge::class.java) `when`(mock.sayHello()).thenReturn("Hello") `when`(mock.sayBye()).thenReturn("Bye")
  4. mockito-kotlin // Kotlin import com.nhaarman.mockito_kotlin.* val mock = mock<Hoge> {

    on { sayHello() } doReturn "Hello" on { sayBye() } doReturn "Bye" }