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
When using verifySequence and trying to use multiple instances of any() as a matcher for a value class parameter it should work.
Current Behavior
The first any() matcher works. Subsequent any() matchers fail.
Failure Information (for bugs)
I've looked at #633 and #152 which seem to cover off the general case of using value classes. I've not found anything covering my verifySequence issue however. I note a workaround further down which I am going to use for now but thought best to raise this.
Steps to Reproduce
Minimal code below. If you comment out the failing case (which is what I want to work) then the verify exactly 3 version does work, which for now is an acceptable workaround. Would like the sequence version though.
class ValueClassSequenceTest: StringSpec() {
interface MyInterface {
fun doSomething(x: MyValueClass) {
return
}
}
@JvmInline
value class MyValueClass(val something: Int)
init {
"Test repeated call of doSomething" {
val myInterface: MyInterface = mockk(relaxed = true)
myInterface.doSomething(MyValueClass(1))
myInterface.doSomething(MyValueClass(2))
myInterface.doSomething(MyValueClass(3))
// Does NOT work
verifySequence {
myInterface.doSomething(any())
myInterface.doSomething(any()) // Fails - uses a matcher of eq(0) (see below)
myInterface.doSomething(any()) // Fails - uses a matcher of eq(0) (see below)
}
// Note: removing the second/third calls and matchers and leaving only one behind in the sequence
// DOES work.
// Also Works
verify(exactly = 3) {
myInterface.doSomething(any())
}
}
}
}
Context
MockK version: 1.12.2
OS: macOS
Kotlin version: 1.6.0
JDK version: 17
JUnit version: kotest 4.6.3
Type of test: unit test
Failure Logs
Note that first matcher is correct, second and third are not.
Verification failed: calls are not exactly matching verification sequence
Matchers:
+MyInterface(#1).doSomething-MR0IliI(any()))
MyInterface(#1).doSomething-MR0IliI(eq(0)))
MyInterface(#1).doSomething-MR0IliI(eq(0)))
Calls:
1) MyInterface(#1).doSomething-MR0IliI(1)
2) MyInterface(#1).doSomething-MR0IliI(2)
3) +MyInterface(#1).doSomething-MR0IliI(3)
The text was updated successfully, but these errors were encountered:
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.
Prerequisites
Please answer the following questions for yourself before submitting an issue.
Expected Behavior
When using
verifySequence
and trying to use multiple instances ofany()
as a matcher for a value class parameter it should work.Current Behavior
The first
any()
matcher works. Subsequentany()
matchers fail.Failure Information (for bugs)
I've looked at #633 and #152 which seem to cover off the general case of using value classes. I've not found anything covering my
verifySequence
issue however. I note a workaround further down which I am going to use for now but thought best to raise this.Steps to Reproduce
Minimal code below. If you comment out the failing case (which is what I want to work) then the verify exactly 3 version does work, which for now is an acceptable workaround. Would like the sequence version though.
Context
Failure Logs
Note that first matcher is correct, second and third are not.
The text was updated successfully, but these errors were encountered: