Skip to content

Instantly share code, notes, and snippets.

@sukyology

sukyology/block11.java Secret

Created Jan 17, 2021
Embed
What would you like to do?
class FieldExists {
@JvmField
var field: String = "Hello"
}
class ExampleTest {
@Test
fun `field exists class mocking`() {
val fieldExists = mockk<FieldExists>()
assertEquals("Hello", fieldExists.field)
// java.lang.AssertionError:
// Expected :Hello
// Actual :null
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment