Skip to content

Instantly share code, notes, and snippets.

@ditn
Created March 6, 2018 17:30
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/74048f746bf66221be3311cea3b81bb2 to your computer and use it in GitHub Desktop.
Save ditn/74048f746bf66221be3311cea3b81bb2 to your computer and use it in GitHub Desktop.
An example of a better converted Kotlin class
class ExampleTest {
private val subject: ClassToTest = mock()
@Test
fun `verify this causes that`() {
// Arrange
val aValue = 10
whenever(mockedClass.getValue()).thenReturn(aValue)
// Act
val result = subject.callFunctionToBeTested(mockedClass)
// Assert
verify(mockedClass).getValue()
verify(mockedClass).someSideEffect()
result `should equal` aValue
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment