Sample app with basic settings to start developing an app with unit test included. This application only demonstrates the use of Robolectric and Mockito.
- Clone the repo to your local development machine.
- Import the app using the build.gradle file in the root folder.
- Add unit test in the build varians tab in android studio. At this point Android Studio will detect the test folder located at src.
- Add a new JUnit configuration
- Assign a name to the configuration (Use a self explanatory name for each test file. eg. MainActivityTest)
- Choose app as module.
- Select MainActivityTest as test class.
- Add
$MODULE_DIR$ as working directory, otherwise Robolectric will through an error (Only for mac users). - Click on Apply then OK.
- Run the configuration that you've just created.
There is also a Test for the EmailValidator utils file. To run the test follow the same procedure as before, but select EmailValidatorTest class.
The main idea behind this repo is to set a clean start for every user that intends to start writing apps with tests that validate functionality through a project lifetime.
Feel free to contribute and add additional test cases that were not included here.
I've also written a medium post explaining a bit the importance of testing an app. Please visit if you have some spare time :)
Some additional test cases can involve networking, Location APIs and layout tests for example.