📄️ Taking a screenshot of an area less than that of the entire Activity
It is often desirable to capture only a portion of your screen or to capture a single View.
📄️ Changing the Locale in a test
API 24+
📄️ Changing the font scale in a test
Testify allows you to change the current Activity scaling factor for fonts, relative to the base density scaling. This allows you to simulate the impact of a user modifying the default font size on their device, such as tiny, large or huge.
📄️ Increase the matching tolerance
In some cases, the captured screenshot may inherently contain randomness. It may then be desirable to allow for an inexact matching. By default, Testify employs an exact, pixel-by-pixel matching algorithm.
📄️ Using @TestifyLayout with library projects
The TestifyLayout annotation allows you to specify a layout resource to be automatically loaded into the host Activity for testing.
📄️ Passing Intent extras to the Activity under test
Some activities may require a Bundle of additional information called extras. Extras can be used to provide extended information to the component. For example, if we have a action to send an e-mail message, we could also include extra pieces of data here to supply a subject, body, etc.
📄️ Specifying a layout resource programmatically
As an alternative to using the TestifyLayout annotation, you may also specific a layout file to be loaded programmatically.
📄️ Use Espresso UI tests with Testify
ScreenshotRule.setEspressoActions accepts a lambda of type EspressoActions in which you may define any number of Espresso actions. These actions are executed after the activity is fully inflated and any view modifications have been applied.
📄️ Writing a test in Java
📄️ Changing the orientation of the screen
Use the setOrientation method to select between portrait and landscape mode.
📄️ Debugging with the Layout Inspector
You may use Android Studio's Layout Inspector in conjunction with your screenshot test. It can sometimes be useful to pause your test so that you can capture the layout hierarchy for further debugging in Android Studio. In order to do so, invoke the setLayoutInspectionModeEnabled method on the test rule. This will pause the test after all ViewModifications have been applied and prior to the screenshot being taken. The test is paused for 5 minutes, allowing plenty of time to capture the layout.
📄️ Selecting an alternative capture method
Testify provides three bitmap capture method. Each method will capture slightly different results based primarily on API level.
📄️ Force software rendering
In some instances it may be desirable to use the software renderer, not Android's default hardware renderer. Differences in GPU hardware from device to device (and emulators running on different architectures) may cause flakiness in rendering.
📄️ Excluding a region from the comparison
For some Views, it may be impossible to guarantee a stable, consistent rendering. For instance, if the content is dynamic or randomized.
📄️ Placing the keyboard focus on a specific view
It's possible that users can navigate your app using a keyboard, because the Android system enables most of the necessary behaviors by default.
📄️ Customizing the captured bitmap
Testify provides the setCaptureMethod() on ScreenshotRule which can be used to override the default mechanism for creating a bitmap
📄️ Providing a custom comparison method
You can customize the algorithm used to compare the captured bitmap against the baseline by using the setCompareMethod() on ScreenshotRule.
📄️ Configuring Testify to write to the SDCard
By default, Testify will write baseline images to the data/data/com.application.package/app_images/ directory of your device emulator.
📄️ Multi-user support
Testify provides support for emulators running in multi-user configuration.
📄️ Configuring Testify to run on Gradle managed device
Starting from API levels