Now we are working on multiple projects on the Android team, we felt it necessary to begin sharing some commonly used code across projects. And now we are heavility using UI testing in these projects, we found that the same custom actions and matchers were being used in multiple places.
That's where Biscotti comes in. Biscotti is a simple collection of Custom Actions and Matchers used within Espresso tests.
The ingredients of our Biscotti currently consist of:
-
withTextColor() - Matches a
TextView
orEditText
if it has the given text color -
withBackground() - Matches a
View
if it has the given background color
- withCustomConstraints() - Perform the given view action whilst also defining a custom constraint to be applied
-
assertAppShortcutDoesNotExist() - Check that an app shortcut for the given app name, with the given label, does not exist
-
assertAppShortcutExists() - Check that an app shortcut for the given app name, with the given label, exists
-
verifyLinkOpen() - Verify a link is opened after performing an action
-
verifyActivityLaunched() - Verify an Activity with a given name is launched
-
verifyExpectedIntent() - Verify an Intent with a given Matcher is launched
-
changeOrientationToLandscape - Change the test devices orientation to landscape
-
changeOrientationToPortrait - Change the test devices orientation to portrait
-
closeSoftKeyboardWithDelay - Close the software keyboard, followed by applying a delay using the given delay value
To use Biscotti in your projects, add the following to your root build.gradle file:
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
Followed by the dependancy in your app level build.gradle file:
androidTestCompile 'com.github.bufferapp:Biscotti:-SNAPSHOT'
or
androidTestImplementation 'com.github.bufferapp:Biscotti:-SNAPSHOT'