Add argument captorsΒ #262
Description
Description
I think it would be nice to build an ArgumentCaptor
interface and argumentCaptor
struct that extends Matcher
through composition, but store the value of the arguments before the "match" step. Those argument values could then be retrieved for later assertions (very close to how Mockito's ArgumentCaptors work in Java) https://static.javadoc.io/org.mockito/mockito-core/2.6.9/org/mockito/ArgumentCaptor.html
Use Case
I recently ran into a situation where I wanted to write a test that asserted something about the contents of an argument (a slice of struct pointers) passed to a mocked method. Using matchers as they currently exist (i.e. eqMatcher
), I couldn't find a good way to do that without already knowing the memory addresses of the pointers in the slice.