You’ve got two issues here:
- Use
launchFragmentInContainer
instead oflaunchFragment
when creating your scenario. If you want to test your UI within your Fragment you need to use that API. See: Test your fragments | Android Developers - Do not use
scenario.onFragment {}
when doing your check. That function is only needed if you need to call functions or access properties within the Fragment. You do not need it to perform Espresso validations. Pull thatonView()...
code out of thatscenario.onFragment {}
lambda expression and just invoke it the same way that you did when you clicked the checkbox.
I hope that helped.