Unit tests
Having well-written unit tests in your project does not only assure quality, it also makes it easy to check if new code breaks any functionality. Android Studio and the Gradle Android plugin have native support for unit tests, but you need to configure a few things before you can use them.
JUnit
JUnit is an extremely popular unit testing library that has been around for over a decade. It makes it easy to write tests while making sure that they are also easy to read. Keep in mind that these particular unit tests are only useful for testing business logic and not code that is related to the Android SDK.
Before you can start writing JUnit tests for your Android project, you need to create a directory for the tests. By convention, this directory is called test
and it should be on the same level as your main directory. The directory structure should look like this:
app └─── src ├─── main │ ├─── java │ │ └─── com.example.app │ └───res └─── test ...