
ADB-Anim, a homebrew tap for toggling android animations
Here at N26 we are automating our UI tests using Espresso.When dealing with Espresso tests you can find yourself with a lot of flakiness.
This can be caused by many reasons (network calls, different devices and OS versions, etc…). One of the most common causes of flaky tests are the device animations. So, what most devs do is to disable them before running the tests.
It could be quite annoying having to enable/disable animations manually using the android system. Especially when you need to do it many times a day. Of course, there are gradle tasks available on Android Studio(AS) that perform this actions, but they could take some time to run and you still need to type them using ./gradlew or just run them using the AS UI
So I’ve decided to automate this process a little bit with a different approach
Using bash scripts
My first approach was to use 2 bash scripts to enable and disable animations using ‘adb shell’ commands
And adding aliases to my .zshrc file so that i could just invoke those scripts whenever I want
This solution is ok but I figured what the hell, if i’m having this issue, then other people could use these scripts and make their life easier.
So, why not give it a try on writing a new brew tap for these scripts
Creating my own brew tap
There are many articles related to writing your own brew formulas or even the homebrew documentation so I won’t cover this here.
First, you need to enable this tap into your homebrew
brew tap horowitz/adbanim
This is telling brew to add this tap from this the adbanim tap repository
Then, you are ready to install adb-anim using homebrew
brew install adb-anim
Using adb-anim
To Enable animations
adb-anim -e
Or disable animations
adb-anim -d
That’s it! Hopefully this will save some of your time and definitely some patience