Skip to content

Android Tests

Lopez Mikhael edited this page Jun 5, 2020 · 1 revision
Type Name
Android Instrument Test AndroidXTest (Runner, JUnit, Rules) / Espresso (Core, Intents, Contrib)

Room Database:

To really test the database of your application, you need to use instrumental tests to launch the application and create the database. Each test creates a database and deletes it at the end. It is easily implemented with Room.

👀 You can check a full example here: RepoDaoTest.kt

UI & UseCase Test:

This architecture, in particular with MVI, makes it very easy to test your views. To do this, simply send a ViewModel to your view and check that the graphic elements (and only them) are clearly visible there with Espresso.

👀 You can check a full example here: RepoActivityTest.kt, RepoRobot.kt

After visually testing each screen you must test their sequence (use cases).
Just use the same Robot in each scene to trigger interactions and navigate from screen to screen.

👀 You can check a full example here: AppUseCaseTest.kt

I also invite you to watch and use function extensions of the example project to facilitate your UI tests with Expresso: EspressoExtension.kt

Clone this wiki locally