• Home
Name Date Size #Lines LOC

..--

backup/03-May-2024-14,89110,337

config/03-May-2024-11

src/com/android/server/03-May-2024-1,9001,263

Android.mkD03-May-20242.7 KiB9041

READMED03-May-20241.1 KiB2418

README

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