Has anyone experienced flaky tests without output ...
# koin
a
Has anyone experienced flaky tests without output
java.lang.IllegalStateException at KoinContextHandler.kt
From
./gradlew testDebug
? I’ve used koin before in a few projects and this one is internal. It extends
AutoCloseKoinTest
and fails for certain files exactly every other time. Using
./gradlew clean testDebug
fixes it, but I’m not sure what the issue is. Curious if anyone has experienced the same thing
t
Could you provide the full stacktrace?
a
Copy code
java.lang.IllegalStateException: A KoinContext is already started
at org.koin.core.context.KoinContextHandler.register(KoinContextHandler.kt:49)
at org.koin.core.context.ContextFunctionsKt.startKoin(ContextFunctions.kt:36)
at org.koin.core.context.ContextFunctionsKt.startKoin$default(ContextFunctions.kt:35)
at [TestApplication].onCreate([TestApplication].kt:12)
at org.robolectric.android.internal.AndroidTestEnvironment.lambda$installAndCreateApplication$0(AndroidTestEnvironment.java:276)
at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:75)
at org.robolectric.android.internal.AndroidTestEnvironment.installAndCreateApplication(AndroidTestEnvironment.java:276)
at org.robolectric.android.internal.AndroidTestEnvironment.setUpApplicationState(AndroidTestEnvironment.java:169)
at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:301)
at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:243)
at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:89)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
This is for robolectric with a config pointing to our test application class. Koin is started in application on start
a
for RoboElectric test, Koin is already started from the Android app context (as a regular app)
a
Yes, so I’ve attached a test application which replaces the main one, and I no longer start koin myself within a given unit test
Implementation wise I do believe that koin is setup properly. It’s weird that the test is failing every other time exactly without clean, and it works if we clean the project beforehand