-
Notifications
You must be signed in to change notification settings - Fork 609
Show file and line number of call during errors #25
Conversation
This commit makes erroneous calls show their origin. Unexpected calls show where they happened. Missing calls and improper expectations show where they were set up in the tests. This information is printed after each error message in square brackets.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
@ooesili Looks good to me. I'm not using any special test runner, just |
@dsymonds Could I get some feedback on this? |
This looks like a useful feature... Can one of the maintainers take a look? |
This commit makes erroneous calls show their origin. Unexpected calls show where they happened. Missing calls and improper expectations show where they were set up in the tests. This information is printed after each error message in square brackets. This commit was originally: ooesili@76f75d8 and a PR for it: golang#25. But there were minor conflicts with master from 2 aug 2017: golang@13f3609, which I fixed.
This commit makes erroneous calls show their origin. Unexpected calls show where they happened. Missing calls and improper expectations show where they were set up in the tests. This information is printed after each error message in square brackets. This commit was originally: ooesili@76f75d8 and a PR for it: golang#25. But there were minor conflicts with master from 2 aug 2017: golang@13f3609, which I fixed.
This commit makes erroneous calls show their origin. Unexpected calls show where they happened. Missing calls and improper expectations show where they were set up in the tests. This information is printed after each error message in square brackets. This commit was originally: ooesili@76f75d8 and a PR for it: golang#25. But there were minor conflicts with master from 2 aug 2017: golang@13f3609, which I fixed.
Any news on this? Would be a huge imrovement, since I always spent a lot of time which of the expected calls in my test did not trigger or the other way around which did trigger without expectation. This is really hard if you have a lot of tests on the same mock object / function. |
This change was pulled through #97. Should be working now. Please re-open if I misunderstood. |
Show file and line number of call during errors
This commit makes erroneous calls show their origin. Unexpected calls
show where they happened. Missing calls and improper expectations show
where they were set up in the tests. This information is printed after
each error message in square brackets.
Here is an example of the output:
I had a hard time deciding how I wanted the output to look so I'd love some feedback. I originally had the file and line number displayed as a prefix like
mocktest_test.go:14: missing call(s) to ...
, which looks great when used with Ginkgo, but looks awkward with plaingo test
, since the prefixes were doubledcontroller.go:164: mocktest_test.go:14: missing call(s) to ...
.It would be trivial to also add the package/function name of the caller to this output. I decided against that since the file and line number is generally all I'm after when debugging.