Skip to content

Instantly share code, notes, and snippets.

@ditn
Last active March 20, 2018 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ditn/fba4164fee56c179b31676ace26538b4 to your computer and use it in GitHub Desktop.
Save ditn/fba4164fee56c179b31676ace26538b4 to your computer and use it in GitHub Desktop.
An example of a poorly converted Kotlin class
class ExampleTest {
@Mock private var subject: ClassToTest?
@Before
fun setUp() {
MockitoAnnotations.initMocks(this)
}
@Test
fun verifyThisCausesThat() {
// Arrange
val aValue = 10
`when`(mockedClass.getValue()).thenReturn(aValue)
// Act
val result = subject!!.callFunctionToBeTested(mockedClass)
// Assert
verify(mockedClass).getValue()
verify(mockedClass).someSideEffect()
assertEquals(aValue, result)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment