Hi again! I did not find any related thread on thi...
# mockk
a
Hi again! I did not find any related thread on this channel, so will ask. When I am doing some sequence verification and one of the call arguments does not match - I get:
Copy code
Verification failed: calls are not exactly matching verification sequence
which is fine. However the error message is not descriptive. It points to the high level problem (something wrong with whole sequence) instead of saying something like: "Hey, your sequence failed because of argument matching here" Are there a way to get more descriptive message when something like that happens? Is it me that incorrectly structure the test. Attaching simplified version of the test:
Copy code
@Test
    fun `when connect`() {
        // When
        subject.connect()

        // Then
        verifySequence {
            mockStateListener(State.CONNECTING)
            mockPlatformSocket.openSocket(any())
        }
    }
And the error:
Copy code
Verification failed: calls are not exactly matching verification sequence

Matchers: 
Function1(#1).invoke(eq(CONNECTING)))
+PlatformSocket(#2).openSocket())

Calls:
1) Function1(#1).invoke(CONNECTED)
2) +PlatformSocket(#2).openSocket()

Stack traces:
m
well it is logging the list of matchers and the actual calls that happened the calls that were matched have a + aside and the ones that were not don’t
how would you like to improve this?
a
Sorry, that was a bad example, as it is easy to see the difference between 2 states. In real life I am doing some long string request validation. lets say something like that
Copy code
Verification failed: calls are not exactly matching verification sequence

Matchers: 
+Function1(#13).invoke(eq(CONNECTING)))
+PlatformSocket(#14).openSocket(any()))
+Function1(#13).invoke(eq(CONNECTED)))
PlatformSocket(#14).sendMessage(eq({"token":"1234567890","id":"id","guestInformation":{"email":"<mailto:peter.parker@marvel.com|peter.parker@marvel.com>","phoneNumber":"911","firstName":"Peter","lastName":"Parker"},"action":"configureSession"})))

Calls:
1) +Function1(#13).invoke(CONNECTING)
2) +PlatformSocket(#14).openSocket()
3) +Function1(#13).invoke(CONNECTED)
4) PlatformSocket(#14).sendMessage({"token":"1234567890","id":"id","guestInformation":{"email":"<mailto:peter.parker@marvel.com|peter.parker@marvel.com>","phoneNumber":"911","firstName":"Peter","lastName":"Parker"},"action":"getAttachment"})

Stack traces:
1)                                                           io.mockk.impl.InternalPlatform.captureStackTrace                      (InternalPlatform.kt:121)
In this case the difference was with
action
key. it was expected to be
configureSession
but was
getAttachment
. It will be helpful to get the argument matcher exception with details what did not match
m
ah i see what you mean now 🙂
yes there is some possible room for improvement there
🙏 1