jnthn / test-mock

Test::Mock - a module for simply generating and checking mock objects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Output of the Capture when matching failed

wbiker opened this issue · comments

commented

This is not a bug report instead it is more of a feature request.

I lately work a lot with Test::Mock and I really love it. It makes the whole testing a lot of easier with less boilerplate.
One think I am missing, though, is to see what the current Capture was when a match fails.
For example:

not ok 1 - called get with arguments matching \("http://something.com/feedback-request/1/type")
    # Failed test 'called get with arguments matching \("http://something.com/feedback-request/1/type")'
    # at vendor#sources/089C1207C1C5AF2F47A153CEA3778EF6A26FE0DC (Test::Mock) line 37

It would be great to have some output like

not ok 1 - called get with arguments matching \("http://something.com/feedback-request/1/type")
    # got 'called get with arguments matching \("http://something.com/feedback-request/1/type")'
    # expected 'called get with arguments matching \("http://something.com/feedback-requests/1/type")'
    # at vendor#sources/089C1207C1C5AF2F47A153CEA3778EF6A26FE0DC (Test::Mock) line 37

Note the missing 's'. Its hard to find mistakes like that without knowing what was matched against.

I'd also value something like this. But I think it's a bit unclear which call of the potentially many check-mock should list for a given check. Just listing all calls matching the method name would be an option.
Alternatively allowing introspection of all the calls via a separate method would also help.