Integration tests (aka feature specifications) are an essential part of test-driven development (TDD). To verify that our application as a whole works, we simulate user interaction with our app and check that our app, as a black box, exhibits the correct behaviors. This allows us to catch regressions that might arise from refactoring and reduces the need for repetitive manual testing on the slow Android emulators. Integration tests can also help ensure that requirements are met by acting as acceptance criteria.
In order to create integration tests on Android, we write feature specs with Cucumber and Appium. Checkout Originate’s complete guide for writing and running Android feature specs.
A number of testing options are available for Android applications. Some of the most popular/widely used frameworks are listed below.
Mockito - A java mocking framework that now supports Android! We’ve used this on the Newaer project with good results.
Robolectric - Android unit test framework that decouples the the android-sdk.jar so you can test within your JVM on your workstation.
Robotium - Another automation framework that seems to be popular. We haven’t used this on any of our projects yet.
UI Automator - Google’s newly released UI functional testing framework.
RoboSpock - JVM-based unit-tests.
Appium - based on the Selenium web-driver. Useful for UI tests and integration tests.