📄️ 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
Testify is fully backwards compatible with Java.
📄️ Changing the orientation of the screen
Use the orientation configuration 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, set the pauseForInspection configuration property on the test rule to true. 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 built-in bitmap capture methods. Each method will capture slightly different results based primarily on API level. In addition, a Fullscreen Capture Method is provided as an optional extension.
📄️ 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. For this reason, Testify provides the option to specify a series of rectangles to exclude from the comparison. All pixels in these rectangles are ignored and only pixels not contained will be compared.
📄️ Placing the keyboard focus on a specific view
As users can navigate your app using a keyboard (by pressing the TAB key, for example), it may be desirable to place the keyboard focus on a specific View prior to taking a screenshot.
📄️ Customizing the captured bitmap
In some instances, it may be useful to modify or customize the captured Bitmap. For example, you may wish to annotate the screenshot with certain diagnostic information, print the name of the test, or add a watermark.
📄️ Providing a custom comparison method
There are many scenarios where
📄️ 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
📄️ Configuring Testify for Android Library Projects
An Android library is structurally the same as an Android app module. It includes everything needed to build an app, including source code, resource files, and an Android manifest. So, it is often necessary to want to use screenshot testing with your library.