esdudnik
09/20/2018, 3:33 PMtestOptions {
unitTests {
includeAndroidResources = true
}
}
all of my tests crashed with strange errors.
From the beginning I received
org.koin.error.AlreadyStartedException: Koin is already started. Run startKoin only once or use loadKoinModules
and when I added
testImplementation 'org.koin:koin-test:1.0.0'
I received error
java.lang.NoSuchMethodError: org.koin.standalone.StandAloneContext.startKoin$default(Lorg/koin/standalone/StandAloneContext;Ljava/util/List;ZLjava/util/Map;ILjava/lang/Object;)Lorg/koin/Koin;
I extend my test classes from AutoCloseKoinTest() but errors stay the same.
Do anybody faced this problem? Or probably somebody know how to fix it.
I will appreciate any help.tapchicoma
09/20/2018, 4:28 PM@Config(application = TestApplication.class)
or don't start koin in test itselfesdudnik
09/21/2018, 8:59 AM@RunWith(RobolectricTestRunner::class)
@Config(manifest = Config.NONE)
class CacheTest {
@Before
fun setup() {
...
}
@Test
fun getDefaultCachePath {
whenever(...)
ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED)
assertEquals(...)
}
}
So there is no actual any koin logic inside test.
But using
testOptions {
unitTests {
includeAndroidResources = true
}
}
probably cause test start my app classtapchicoma
09/24/2018, 10:55 AMstartKoin()
is called, so try to provide your own test application classtapchicoma
09/24/2018, 10:56 AMtapchicoma
09/24/2018, 10:58 AM