Created
August 10, 2018 03:58
-
-
Save oakkub/51670de1768db1d621172948147a7248 to your computer and use it in GitHub Desktop.
Set value to private field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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