Skip to content

Instantly share code, notes, and snippets.

@fbcbl
Last active September 29, 2017 22:18
Show Gist options
  • Save fbcbl/2ab8ad9e35f712b2caeb55d0f8887d76 to your computer and use it in GitHub Desktop.
Save fbcbl/2ab8ad9e35f712b2caeb55d0f8887d76 to your computer and use it in GitHub Desktop.
Kotlin Testing Part 1 Test
import org.junit.Before
import org.junit.Test
import org.junit.Assert.*
import org.mockito.Mock
import org.mockito.Mockito
import org.mockito.MockitoAnnotations
class GreeterTest {
@Mock
lateinit var user: User
lateinit var tested: Greeter
@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
tested = Greeter(user)
}
@Test
fun englishGreetIsCorrect() {
Mockito.`when`(user.fullName()).thenReturn("Fábio Carballo")
assertEquals("Hello, Fábio Carballo!", tested.getEnglishGreeting())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment