**Root cause** Robolectric doesn't like to launch a spy'ed fragment. You will get an error like java.lang.IllegalStateException: Can't access ViewModels from detached fragment Since the test itself doesn't require launch a fragment, I removed the setup part and renamed the test. Bug: 279082331 Test: atest ToggleFeaturePreferenceFragmentTest Change-Id: Iafc431fd8c9cf7812ea99164e5e85683f3e0c121
Running Settings Robolectric tests
The full suite
$ croot
$ make RunSettingsRoboTests
Running a single test class
$ croot
$ make RunSettingsRoboTests ROBOTEST_FILTER=<ClassName>
For example:
make RunSettingsRoboTests ROBOTEST_FILTER=CodeInspectionTest
You can also use partial class name in ROBOTEST_FILTER. If the partial class name matches multiple file names, all of them will be executed.