Please answer the following questions for yourself before submitting an issue.
AndroidX JVM unit tests passed successfully.
Test failed when the test run on JVM.
It is a success on a real device.
Please provide detailed steps for reproducing the issue.
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
java.lang.Exception: Main looper has queued unexecuted runnables. This might be the cause of the test failure. You might need a shadowOf(getMainLooper()).idle() call.
at org.robolectric.android.internal.AndroidTestEnvironment.checkStateAfterTestFailure(AndroidTestEnvironment.java:470)
at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:548)
at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:252)
at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:89)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ExceptionInInitializerError
at // remove package name
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at "packagename".MockWebServerRule$apply$1.evaluate(MockWebServerRule.kt:22)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:546)
... 6 more
Caused by: io.mockk.MockKException: Failed to load plugin. io.mockk.proxy.jvm.JvmMockKAgentFactory Check if you included 'io.mockk:mockk-android' dependency instead of 'io.mockk:mockk'
at io.mockk.impl.JvmMockKGateway.<init>(JvmMockKGateway.kt:186)
at io.mockk.impl.JvmMockKGateway.<clinit>(JvmMockKGateway.kt:172)
... 20 more
Caused by: java.lang.ClassNotFoundException: io.mockk.proxy.jvm.JvmMockKAgentFactory
at org.robolectric.internal.bytecode.SandboxClassLoader.getByteCode(SandboxClassLoader.java:164)
at org.robolectric.internal.bytecode.SandboxClassLoader.maybeInstrumentClass(SandboxClassLoader.java:119)
at org.robolectric.internal.bytecode.SandboxClassLoader.lambda$findClass$0(SandboxClassLoader.java:112)
at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:53)
at org.robolectric.internal.bytecode.SandboxClassLoader.findClass(SandboxClassLoader.java:111)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at io.mockk.impl.JvmMockKGateway.<init>(JvmMockKGateway.kt:184)
... 21 more
// objenesis exclusion for workaround in mockk 1.9.3 (https://github.com/mockk/mockk/issues/281)
testImplementation("io.mockk:mockk-android:1.9.3") {
exclude(module = "objenesis")
}
testImplementation("org.objenesis:objenesis:2.6")
//////
fun inputAmount_startPayment() {
val navController = mockk<NavController>(relaxed = true)
....
}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you are sure that this issue is important and should not be marked as stale just ask to put an important label.
So here seems to be an issue with linking another dependency.
The exception says what is wrong:
Check if you included 'io.mockk:mockk-android' dependency instead of 'io.mockk:mockk'
So for unit tests io.mockk:mockk should be used and for Android Instrumented tests io.mockk:mockk-android
Most helpful comment
So here seems to be an issue with linking another dependency.
The exception says what is wrong:
So for unit tests
io.mockk:mockkshould be used and for Android Instrumented testsio.mockk:mockk-android