①A new test runner for Android JUnit3/JUnit4 Support ②Instrumentation Registry ③Test Filtering ④Intent Monitoring/Stubbing ⑤Activity/Application Lifecycle Monitoring
You can use the
InstrumentationRegistry
class to access information related to your test run. This class includes the
Instrumentation
object, target app
Context
object, test app
Context
object, and the command line arguments passed into your test. This data is useful when you are writing tests using the UI Automator framework or when writing tests that have dependencies on the
Instrumentation
or
Context
objects.
@RequiresDevice
: Specifies that the test should run only on physical devices, not on emulators.
@SdkSupress
: Suppresses the test from running on a lower Android API level than the given level. For example, to suppress tests on all API levels lower than 18 from running, use the annotation @SDKSupress(minSdkVersion=18).
@SmallTest
,
@MediumTest
, and
@LargeTest
: Classify how long a test should take to run, and consequently, how frequently you can run the test.
@SdkSuppress(minSdkVersion=15)
@Test
public void featureWithMinSdk15() {
@RequiresDevice
@Test
public void SomeDeviceSpecificFeature() {
}