Getting started with JUnit Tests
Let’s test our Koin injected application
First, add the Koin dependency like below:
FLet’s create a Repository to provide some data (
A Presenter class, for consuming this data:
applicationContext function to declare a module. Let’s declare our first component:
Writing our first Test
To make our first test, let’s write a simple Junit test file and extend it with
KoinTest. We will be able then, to use
by inject() operators.
For each test, we start startKoin() and close Koin context closeKoin().
You can even make Mock testing directly into MyPresenter, or test MyRepository. Those components doesn’t have any link with Koin API.
You have finished this starting tutorial. Below are some topics for further reading: