'Unresolved reference:test in KoinTest
I'm trying to do some test with Koin, but I'm getting the "Unresolved reference:KoinTest' howeber, seems that is doing the imports correctly, because I can't see any error in the code. Is only when I try to run the test.
I've tried to clean and rebuild the project and reinit android studio, but still the problem
TEST CLASS
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.koin.core.context.startKoin
import org.koin.core.context.stopKoin
import org.koin.test.KoinTest
import salva.perez.cabify.di.applicationModule
import org.koin.test.inject
class VoucherPresenterTest : KoinTest {
private val presenter: VoucherContract.Presenter by inject()
@Before
fun before() {
startKoin {
modules(applicationModule)
}
}
@After
fun after() {
stopKoin()
}
@Test
fun testInitViewCorrectly() {
...
}
}
GRADLE
implementation 'org.koin:koin-android:2.0.1'
testImplementation 'org.koin:koin-test:2.0.1'
Solution 1:[1]
Consider using androidTestImplementation if you want to use it in your androidTest and debugImplementation if you want to use it in unitTest as well.
Solution 2:[2]
Sorry for being so late(just 2 years late) but if there is someone that is still looking for this solution.. You have to put manually the import -> import org.koin.test.inject , to Android recognize the KoinTest interface.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Levon Petrosyan |
| Solution 2 | Leo Santana |
