# android.support.test.rule

# android.support.test.rule

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

## Classes

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ActivityTestRule](https://developer.android.com/reference/android/support/test/rule/ActivityTestRule)\<T extends[Activity](https://developer.android.com/reference/android/app/Activity.html)\> | This rule provides functional testing of a single[Activity](https://developer.android.com/reference/android/app/Activity.html).                                                                                                                                                                                                                                                                                                                                 |
| [DisableOnAndroidDebug](https://developer.android.com/reference/android/support/test/rule/DisableOnAndroidDebug)                                                                                 | The`DisableOnAndroidDebug`Rule allows you to label certain rules to be disabled when debugging.                                                                                                                                                                                                                                                                                                                                                                 |
| [GrantPermissionRule](https://developer.android.com/reference/android/support/test/rule/GrantPermissionRule)                                                                                     | The`GrantPermissionRule`Rule allows granting of runtime permissions on Android M (API 23) and above.                                                                                                                                                                                                                                                                                                                                                            |
| [ServiceTestRule](https://developer.android.com/reference/android/support/test/rule/ServiceTestRule)                                                                                             | A JUnit rule that provides a simplified mechanism to start and shutdown your service before and after the duration of your test.                                                                                                                                                                                                                                                                                                                                |
| [UiThreadTestRule](https://developer.android.com/reference/android/support/test/rule/UiThreadTestRule)                                                                                           | *This class is deprecated. use[UiThreadTest](https://developer.android.com/reference/android/support/test/annotation/UiThreadTest)directly without this rule.[UiThreadTest](https://developer.android.com/reference/android/support/test/annotation/UiThreadTest)is now supported as part of the core Android test runner to provide the ability to run methods annotated with`@Before`and`@After`on the UI thread regardless of what`@Test`is annotated with.* |

-

  ## Classes

  - [ActivityTestRule](https://developer.android.com/reference/android/support/test/rule/ActivityTestRule)
  - [DisableOnAndroidDebug](https://developer.android.com/reference/android/support/test/rule/DisableOnAndroidDebug)
  - [GrantPermissionRule](https://developer.android.com/reference/android/support/test/rule/GrantPermissionRule)
  - [ServiceTestRule](https://developer.android.com/reference/android/support/test/rule/ServiceTestRule)
  - [UiThreadTestRule](https://developer.android.com/reference/android/support/test/rule/UiThreadTestRule)