Posted: 30 Nov 2018 9:41 EST Last activity: 3 Dec 2018 2:37 EST
Mobile testing with Espresso framework
WHAT IS ESPRESSO
Espresso is a framework created by Google company for the purpose of testing of an Android UI. Its code utilizes the code from the application under test and it is proven to be the fastest and most reliable testing tool on the market. With Espresso Web it is possible to perform any action on any web element, not only native ones, so it can be used for testing hybrid applications. Works on real devices as well as emulators and it is possible to run tests at the same time on all connected devices.
IT IS REALLY FAST - and it is most important thing taking into account how many tests we may have. UI tests are slow and costly, it may happen you are not able to run all of them.
IT IS LESS FLAKY - Automated DevOps process requires fast and reliable feedback and it cannot be provided by tools like Appium. Tests written with native tools are much less flaky.
IT IS EASY TO SETUP - Setup process on local machine is easier than Appium, android developers feel most comfortable in the mobile SDK language which they use every day.
IT GIVES MORE CONTROL OVER THE APPLICATION - it is white box testing, Espresso is inside the application, it has access to and knows how to use the code that actually runs the application for more thorough testing of each element.
WHY NOT APPIUM?
Appium is cross-platform tool used by big number of people and it definitely has its pluses like supporting multiple programming languages, no need to recompile application. It is also easy to learn and work with.
The main thesis put forward by the supporters of Appium is that moving from Appium to Espresso or XCUITests makes it necessary to develope tests for both platforms in two custom languages as well as maintaining twice the number of tests. In reality Appium uses XCUI and UIAutomator (part of android test library which also includes espresso) and for testing cross platform apps there will always be some degree of technical complexity involved with Appium.
In Appium's framework we may have custom page objects, helpers for these platforms, maintaining them is not easier than maintaining two custom frameworks.
Changes in android and iOS platforms accelerated last time and Appium is often late when changes are done in mentioned ones what means we have delays in our day-to-day testing. Also android experience is supposed to be different to the iOS experience, framework becomes complicated to handle both of them.
Software testing services need highly productive new technologies that are aligned with the organization's strategic objectives. There are more pro's than con's on switching to Espresso and disadvantages can be mitigated by using proper libraries (page objects) and reducing test code to several simple self-descripting lines.
HOW TO START
Simply download latest Android Studio and follow any commonly available tutorials like this one. You can execute your tests on real device connected with USB cable or built-in android emulator both from Android Studio as well as command line.