I am testing viewmodel and would like to access private field:
val currentTrainingField = viewModel.javaClass.getDeclaredField("currentTraining")
currentTrainingField.isAccessible = true
val currentTraining = currentTrainingField.get(currentSetField)
I receive an error: Can not set com.myapp.Training field com.myapp.WorkoutExerciseViewModel.currentTraining to java.lang.reflect.Field
How should I handle that?
Aucun commentaire:
Enregistrer un commentaire