Skip to content

VictorAlbertos/DeviceAnimationTestRule

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

DeviceAnimationTestRule

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.

SetUp

Add to top level gradle.build file

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

Add to app module gradle.build file

dependencies {
    androidTestImplementation 'com.github.VictorAlbertos:DeviceAnimationTestRule:0.0.3'
}

Usage

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:

Java:

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

or Kotlin:

 companion object {
    @ClassRule
    @JvmField
    val deviceAnimationTestRule = DeviceAnimationTestRule()
}

About

A JUnit rule to disable and enable device animations

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •