petergtz / pegomock

Pegomock is a powerful, yet simple mocking framework for the Go programming language
Apache License 2.0
254 stars 28 forks source link

Diff-style output for verification failures #102

Open jtyers opened 4 years ago

jtyers commented 4 years ago

I have a test making calls to an interface with a fairly large struct. When the test fails owing to a verification failure, I have to scan through the error text to find the differences. Other frameworks I've used display a diff of the input/output (diffing the expected call versus actual call) to allow me to quickly see what is wrong.

Could you add similar diff-style output to pegomock? It would make it much easier to narrow down bugs.

petergtz commented 4 years ago

Hi @jtyers, thanks for reporting this. What you write makes a lot of sense and I wished for the same feature a couple of times in the past. Unfortunately, these days I can't tell when I will be able to implement this. However, I'd be more than happy to merge a PR if you want to contribute.

Should you be interested, then it will probably make sense to quickly discuss here what the current output looks like in your specific case, and what you'd roughly wish for.

BTW, the code portion that does the verification is in: https://github.com/petergtz/pegomock/blob/master/dsl.go#L96-L159

Let me know what you think. Thanks, Peter