You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please answer the following questions for yourself before submitting an issue.
I am running the latest version
I checked the documentation and found no answer
I checked to make sure that this issue has not already been filed
Expected Behavior
To be able to mock Color.argb()
Current Behavior
The following unit test code results in the stacktrace blow:
mockkStatic(Color::class);
every { Color.argb(20, 30, 40, 50) } returns Color.GRAY
val color = Color.argb(20, 30, 40, 50)
assertThat(color).isEqualTo(Color.GRAY)
However the following codes works as expected, and the assertion passes:
mockkStatic(Color::class)
Color.argb(0, 0, 0, 0)
every { Color.argb(20, 30, 40, 50) } returns Color.GRAY
val color = Color.argb(20, 30, 40, 50)
assertThat(color).isEqualTo(Color.GRAY)
The only difference is the call to Color.argb between mockkStatic and every
Im confused why the first code does not work?
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
MockK version:1.12.3
OS: Mac OS 12.2.1
Kotlin version: 1.6.10
JDK version: 11.0.11
JUnit version: 4.13.2
Type of test: unit test
Stack trace
// -----------------------[ YOUR STACK STARTS HERE ] -----------------------
every/verify {} block were run several times. Recorded calls count differ between runs
Round 1: class android.graphics.Color.__staticInitializer__(), class android.graphics.Color.argb(20, 30, 40, 50)
Round 2: class android.graphics.Color.argb(20, 30, 40, 50)
io.mockk.MockKException: every/verify {} block were run several times. Recorded calls count differ between runs
Round 1: class android.graphics.Color.__staticInitializer__(), class android.graphics.Color.argb(20, 30, 40, 50)
Round 2: class android.graphics.Color.argb(20, 30, 40, 50)
at io.mockk.impl.recording.SignatureMatcherDetector.detect$checkAllSameNumberOfCalls(SignatureMatcherDetector.kt:25)
at io.mockk.impl.recording.SignatureMatcherDetector.detect(SignatureMatcherDetector.kt:86)
at io.mockk.impl.recording.states.RecordingState.signMatchers(RecordingState.kt:39)
at io.mockk.impl.recording.states.RecordingState.round(RecordingState.kt:31)
at io.mockk.impl.recording.CommonCallRecorder.round(CommonCallRecorder.kt:50)
at io.mockk.impl.eval.RecordedBlockEvaluator.record(RecordedBlockEvaluator.kt:63)
at io.mockk.impl.eval.EveryBlockEvaluator.every(EveryBlockEvaluator.kt:30)
at io.mockk.MockKDsl.internalEvery(API.kt:93)
at io.mockk.MockKKt.every(MockK.kt:98)
at com.avius.kiosk.ExampleUnitTest.exampleMockkTest(ExampleUnitTest.kt:33)
at java.base@11.0.11/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base@11.0.11/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base@11.0.11/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base@11.0.11/java.lang.reflect.Method.invoke(Method.java:566)
at app//org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at app//org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at app//org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at app//org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at app//org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at app//org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:591)
at app//org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:274)
at app//org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:88)
at java.base@11.0.11/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base@11.0.11/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base@11.0.11/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base@11.0.11/java.lang.Thread.run(Thread.java:829)
// -----------------------[ YOUR STACK TRACE ENDS HERE ] -----------------------
Minimal reproducible code (the gist of this issue)
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.
Please answer the following questions for yourself before submitting an issue.
Expected Behavior
To be able to mock Color.argb()
Current Behavior
The following unit test code results in the stacktrace blow:
However the following codes works as expected, and the assertion passes:
The only difference is the call to
Color.argb
betweenmockkStatic
andevery
Im confused why the first code does not work?
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
Stack trace
Minimal reproducible code (the gist of this issue)
The text was updated successfully, but these errors were encountered: