A JUnit rule to disable and enable device animations
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
device-animation-test-rule Bump version Nov 15, 2016
gradle/wrapper Go public Oct 21, 2016
test-sample Go public Oct 21, 2016
.gitignore Go public Oct 21, 2016
.travis.yml Go public Oct 21, 2016
LICENSE.txt Go public Oct 21, 2016
README.md Update README.md Jan 2, 2017
build.gradle Go public Oct 21, 2016
gradle.properties Go public Oct 21, 2016
gradlew Go public Oct 21, 2016
gradlew.bat Go public Oct 21, 2016
settings.gradle Go public Oct 21, 2016



Running instrumentation tests on Android using Espresso requires disabling animations. DeviceAnimationTestRule is a JUnit rule which disables device animations prior to running any test, and enable them after every test has been executed.

This solution is just a wrapper around the solution proposed by artem-zinnatullin in his blog entry.


Add to top level gradle.build file

allprojects {
    repositories {
        maven { url "https://jitpack.io" }

Add to app module gradle.build file

dependencies {
    androidTestCompile 'com.github.VictorAlbertos:DeviceAnimationTestRule:0.0.2'


Add to Android manifest the next permission:

<uses-permission android:name="android.permission.SET_ANIMATION_SCALE"/>

Declare DeviceAnimationTestRule as an static field annotated with @ClassRule to your suit:

@ClassRule static public DeviceAnimationTestRule
      deviceAnimationTestRule = new DeviceAnimationTestRule();


As it has been documented in this issue, you need to run your tests on devices upon on API 21.