Unit testing Android Apps
I have written about unit testing in other posts so this time I will only focus on how to create a test suite and test cases for Android applications. Writing unit tests for Java is a little different than doing it for other languages like JavaScript because Java is not only a strongly typed language, but also is a lot less dynamic than JavaScript.
Creating a test suite
Good developers create tests for all their projects, and for Android there is an standard place where those tests live. Although you don’t really have to do this, it is recommended that you create a tests/ folder in the root of the Android project under test, at the same level as the src/ folder:
1
2
3
4
5
6
7
8
MyProject/
AndroidManifest.xml
src/
...
tests/
AndroidManifest.xml
src/
...