I started using espresso and wrote some simple UI Tests for clicking on buttons, typing in text and checking if everything is there where it should be. Now I wanted to take a screenshot and test some pixel values, but I can't find a way to do this. Has anyone any suggestions? Is it even possible with espresso?
screenshot-tests-for-android generates deterministic screenshots of views during a test run. By deterministic, we mean that every single run of your tests generates a pixel-perfect screenshot of the app as it would appear on a user's device.
Espresso is a testing framework that helps developers write automation test cases for user interface (UI) testing. It has been developed by Google and aims to provide a simple yet powerful framework. It allows both black-box testing as well as testing of individual components during development cycles.
As espresso tests are simple InstrumentationTestCases, you could use paparazzo and celebrity to take screenshots of your application.
Spoon also as a very nice screenshot system. Sharper than paparazzi but that can only take a screenshot of activities, not dialogs for instance.
And last but not least, since android SDK 16, you can use screencap utility to take very fast and sharp screenshots of an app. I think this solution is really the best but it works only with SDK 16+.
Finally to test screenshots against a reference screenshot, there is no real tools. You can find great ideas of implementation on stack over flow, but up to now, noone came with a reference tool that can be used on android.
There's a tool made by Facebook for comparing screenshots if that's what you're looking for: http://facebook.github.io/screenshot-tests-for-android/
Iterating on UI code is hard. How do you quickly verify that your layout or view changes work correctly in all configurations? screenshot-tests-for-android can solve these problems by providing a test framework that checks for visual differences across changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With