В своей библиотеке я использую стиль Spek-Gherkin для написания тестов. Тем не менее, я новичок в тестировании Android и мне нужен контекст в одном из моих тестов. Я пытался Как получить Android-контекст в мультиплатформенном тесте Android Kotlin? это решение, но не повезло. После использования RobolectricTestRunner я получаю следующую ошибку
No instrumentation registered! Must run under a registering instrumentation.
java.lang.IllegalStateException: No instrumentation registered! Must run under a registering instrumentation.
at androidx.test.platform.app.InstrumentationRegistry.getInstrumentation(InstrumentationRegistry.java:45)
at androidx.test.core.app.ApplicationProvider.getApplicationContext(ApplicationProvider.java:41)
at com.disneystreaming.capability.SetupDevice$1$1$1$1.invoke(SetupDevice.kt:18)
at com.disneystreaming.capability.SetupDevice$1$1$1$1.invoke(SetupDevice.kt:9)
at org.spekframework.spek2.runtime.scope.TestScopeImpl.execute(scopes.kt:136)
at org.spekframework.spek2.runtime.Executor$execute$result$2$1$job$1.invokeSuspend(Executor.kt:74)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:740)