Testing
Some useful material for unit testing on Android:
Samples:
- android-alltest-gradle-sample (link)
Tutorials:
- Android Studio unit testing (link)
Unit Testing
Robolectric
Robolectric is a unit testing framework for Android. The tests run in JVM so there is no need to instantiate an Android emulator to execute them. This makes running them pretty fast. It still provides context emulation as well as many shadow classes so mocking is usually not needed.
Mockito
Mockito is a mock/stub library. It can be used with Robolectric but is not necessary.
- Mockito (link)
UI Testing
Selendroid
Selendroid (link), Selenium for Android
Robotium
Robotium is a set of tools/libraries for UI testing. The principle here is black-box testing of the whole app. These tests require an Android running, meaning that they execute either on a real device or in an emulator. However, the execution is pretty fast even if the tests are being modified because the app does not have to be deployed.
- Robotium (link)
- Robotium Tutorial, Vogella (link)
- Robotium in Android Studio (link)
- Set up Gradle/Android Studio (link)
- Robotium with Android Studio (link), Stack Overflow
- Testing activity in Android Studio (link)
- Useful snippets (link)
- ActivityInstrumentationTestCase2 (link)
- ActivityTestRule (link)
- Using Robotium to test Android Spinners (link)
Espresso
Espresso is Google's UI testing framework.
Spoon
Testing on multiple devices - link
Behaviour-Driven Development (BDD)
BDD is a design philosophy. It is an evolution of Test-Driven Development (TDD) and acceptance testing, and merges the two concepts together.
JBehave
Calabash
Matchers
Hamcrest matchers contain lots of useful matchers for assertions and comparison of elements during tests. Useful for both unit and UI tests.
- Discovering Espresso for Android (link)