Skip to content

Instantly share code, notes, and snippets.

@sukyology
Created January 17, 2021 02:44
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 sukyology/071192f1d141d8d04213a095002d63a4 to your computer and use it in GitHub Desktop.
Save sukyology/071192f1d141d8d04213a095002d63a4 to your computer and use it in GitHub Desktop.
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