Skip to content

Instantly share code, notes, and snippets.

@oakkub
Created August 10, 2018 03:58
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 oakkub/51670de1768db1d621172948147a7248 to your computer and use it in GitHub Desktop.
Save oakkub/51670de1768db1d621172948147a7248 to your computer and use it in GitHub Desktop.
Set value to private field
fun FooViewModel.setMockRepository(mockRepository: FooRepository) {
val repository = FooViewModel::class.java.getDeclaredField("fooRepository")
repository.isAccessible = true
repository.set(this, mockRepository)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment