Monday, November 7, 2016

My team at LinkedIn just released a new version of Test Butler, an Android testing utility that makes your tests more stable and reliable.

The headline feature is the ability to grant runtime permissions from Test Butler on Android Marshmallow and above. Since Test Butler is a system-level application, it can grant these permissions for you without any interaction from the user; you just need to call a single method and the permission will be enabled for your app.

TestButler.grantPermission(permission)

Many Android developers are already granting runtime permissions in their tests by passing the “-g” flag when installing their app for testing:

adb install -g MyApp.apk

Unfortunately, this flag can’t be set when running tests from Android Studio. There is an open feature request in the Android bug tracker asking for support for this, but in the meantime, Test Butler now provides a workaround that developers can use when running tests from Android Studio.

Test Butler currently doesn’t provide a way to revoke runtime permissions from tests, because this feature wouldn’t be very useful; revoking a runtime permission will kill your application process, causing your test to fail.

In addition to permission granting, several bugs and user feature requests have been addressed; check the changelog for the full list. For more info on Test Butler, check out the original announcement blog post.