A typical project in Android Studio contains two directories in which you place tests.
1. Instrumented testing (/src/androidTest/java/)
The androidTest
directory should contain the tests that run on real or virtual devices. Such tests include integration tests, end-to-end tests, and other tests where the JVM alone cannot validate your app's functionality.
With instrumented testing, we are able to verify app logic that needs a real device, so mostly we will verify the UI. We will also use JUnit
and we will add Espresso
.
2. Unit testing (/src/test/java/)
The test
directory should contain the tests that run on your local machine,
such as unit tests.
Unit tests are used to verify that business logic is working right without using a real device.e. We will use JUnit
, hamcrest
, and mockito-kotlin
to achieve this.

More info read this article