equals calls performed by the library internally are recorded
See original GitHub issueExpected Behavior
I expect internal calls done to <mockedObject>.equals(<otherObject>) not being recorded This happens when I have mocked calls with different arguments like
every { obj.call(mock1) } just runs
every { obj.call(mock2) } just runs
I expect confirmVerified not to consider calls being performed internally by the library
Stack trace
at io.mockk.impl.recording.CommonVerificationAcknowledger.acknowledgeVerified(CommonVerificationAcknowledger.kt:36)
at io.mockk.MockKDsl.internalConfirmVerified(API.kt:272)
at io.mockk.MockKKt.confirmVerified(MockK.kt:319)
at data.booking.AcceptedBookingSourceImplTest.wtf(AcceptedBookingSourceImplTest.kt:348)
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:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
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 org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
Code snippet
//
package test
import io.mockk.confirmVerified
import io.mockk.justRun
import io.mockk.mockk
import io.mockk.verify
import org.junit.Test
class InternalEqualsCallTest {
class Arg
class Caller() {
fun call(arg: Arg) {}
}
class TestMe(val caller: Caller) {
fun superCall(arg: Arg) {
caller.call(arg)
}
}
@Test
fun test() {
val caller = mockk<Caller>()
val subject = TestMe(caller)
val arg = mockk<Arg>()
val arg1 = mockk<Arg>()
justRun { caller.call(arg) }
justRun { caller.call(arg1) }
subject.superCall(arg)
verify {
caller.call(arg)
}
confirmVerified(
caller,
arg
)
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
Records - C# reference - Microsoft Learn
For record types, including record struct and readonly record struct , two objects are equal if they are of the same type and...
Read more >Why do I need to override the equals and hashCode methods ...
If only equals is overriden, then when you call myMap.put(first,someValue) first will hash to some bucket and when you call myMap.put(second,someOtherValue) ...
Read more >Mock Functions or Spies Demystified - How Does jest.fn() Work?
Internally jest.fn will track all the calls and will perform the execution of the implementation function itself.
Read more >Bug descriptions — spotbugs 4.7.3 documentation
Invoking System.exit shuts down the entire Java virtual machine. This should only been done when it is appropriate. Such calls make it hard...
Read more >A Unit Testing Practitioner's Guide to Everyday Mockito - Toptal
These calls are recorded and the facts of these calls can be verified (see ... In those cases, Mockito just calls equals() internally...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Seeing the same behavior, with
mockkConstructor
as well (don’t know if that matters)I ran into that, here’s an example test:
Is that a misunderstanding of how
wasNot Called
works or a bug?