1. Use AndroidJunit4 instead of RobolectricTestRunner 2. Use ApplicationProvider instead of RuntimeEnvironment to get context 3. Change Copy Right 4. Create new class and add a function which loads the Settings Resource. 5. remove getOnPreferenceChangeListener. Becasue the error: java.lang.NoSuchMethodError: No virtual method getOnPreferenceChangeListener() Bug: 173004787 Test: atest -c DefaultSubscriptionControllerTest Change-Id: Iac9834f2a47bd8b50234646197a31058ffacaa4b
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.