Home | History | Annotate | Download | only in robotests
      1 This folder is for Robolectric tests inside the platform.
      2 
      3 To 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 
     10 Robolectric loads some classes that it decides from versioned jars of the framework. Since we are
     11 part of the framework some of our classes get loaded from these jars. This is NOT what we want, we
     12 want to test against what we wrote in the tree. Because of this we use a custom test runner,
     13 FrameworkRobolectricTestRunner, that bypasses these jars and loads certain classes from the system
     14 class loader.
     15 
     16 To specify which classes to load use either @SystemLoaderClasses or @SystemLoaderPackages. In
     17 practice:
     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
     20 loaded, such as NoSuchMethodException, put the class involved in the exception in this annotation
     21 and try again.
     22 
     23 Check Android.mk file for more info.
     24