1*d57664e9SAndroid Build Coastguard WorkerThis folder is for Robolectric tests inside the platform. 2*d57664e9SAndroid Build Coastguard Worker 3*d57664e9SAndroid Build Coastguard WorkerTo add a test class annotate it as follows: 4*d57664e9SAndroid Build Coastguard Worker 5*d57664e9SAndroid Build Coastguard Worker@RunWith(FrameworkRobolectricTestRunner.class) 6*d57664e9SAndroid Build Coastguard Worker@Config(manifest = Config.NONE, sdk = 26) 7*d57664e9SAndroid Build Coastguard Worker@SystemLoaderClasses({ClassUnderTest.class, DependencyClasses.class}) 8*d57664e9SAndroid Build Coastguard Worker@SystemLoaderPackages({"com.android.server.yourmodule"}) 9*d57664e9SAndroid Build Coastguard Worker 10*d57664e9SAndroid Build Coastguard WorkerRobolectric loads some classes that it decides from versioned jars of the framework. Since we are 11*d57664e9SAndroid Build Coastguard Workerpart of the framework some of our classes get loaded from these jars. This is NOT what we want, we 12*d57664e9SAndroid Build Coastguard Workerwant to test against what we wrote in the tree. Because of this we use a custom test runner, 13*d57664e9SAndroid Build Coastguard WorkerFrameworkRobolectricTestRunner, that bypasses these jars and loads certain classes from the system 14*d57664e9SAndroid Build Coastguard Workerclass loader. 15*d57664e9SAndroid Build Coastguard Worker 16*d57664e9SAndroid Build Coastguard WorkerTo specify which classes to load use either @SystemLoaderClasses or @SystemLoaderPackages. In 17*d57664e9SAndroid Build Coastguard Workerpractice: 18*d57664e9SAndroid Build Coastguard Worker* You MUST put the class under test here. 19*d57664e9SAndroid Build Coastguard Worker* If you encounter any exceptions that might be caused by a different version of the class being 20*d57664e9SAndroid Build Coastguard Workerloaded, such as NoSuchMethodException, put the class involved in the exception in this annotation 21*d57664e9SAndroid Build Coastguard Workerand try again. 22*d57664e9SAndroid Build Coastguard Worker 23*d57664e9SAndroid Build Coastguard WorkerCheck Android.mk file for more info. 24