hello! it appears that it is not possible to captu...
# mockk
d
hello! it appears that it is not possible to capture arguments to mocked methods based on the other arguments - is that expected? e.g.
Copy code
class MockkCaptorTest {

    @Test
    fun `verify mockk captor behavior`() {
        val simpleMockk = mockk<Simple> {
            every { hello(any(), any()) } answers { "Mocked response for ${arg<String>(0)}, age: ${arg<Int>(1)}" }
        }

        simpleMockk.hello("Bob", 2)
        simpleMockk.hello("Alice", 1)

        val bobsAge = slot<Int>()
        verify {
            simpleMockk.hello("Bob", capture(bobsAge))
        }
        assertEquals(2, bobsAge.captured)
    }
}

class Simple {
    fun hello(name: String, age: Int) = "Hello $name, age: $age"
}
above will actually capture
Alice
age
note: mockito handles this fine
l
i'm not sure you're using capture slots correctly
d
me neither, thats why I'm asking
l
I think the capture should happen on the
every
block
and then you'll use the slot for verifications
However I'm not sure how you can link those parameters
d
well i can pass a mutable list for capturing slots that will capture all of the args but again my problem is that I would have to explicitly capture all of the params
and then iterate over the first one to find out the index of the one i'm interested in
if thats the only option then it is an oversight