Feature request: Add more detailed information to ExpectationViolationException for constraint violations

47 views
Skip to first unread message

Rory

unread,
Aug 14, 2009, 1:23:05 AM8/14/09
to Rhino.Mocks
I have some unit tests which expect several constrains on a method. If
one of the constraints fail, it is impossible to know which one is the
issue based on the message of the thrown exception.

It would be good if this message could be updated to indicate either
the value tested along with the value expected or even better,
indicate which constraint failed?.

Cheers,

Rory

Ayende Rahien

unread,
Aug 14, 2009, 1:25:46 AM8/14/09
to Rhino...@googlegroups.com
Patch would be  welcome.

Iain Waddell

unread,
Aug 14, 2009, 2:15:23 AM8/14/09
to Rhino...@googlegroups.com

Or you could write multiple similar tests and only assert on one constraint in each test. This is what I do for precisely the reason you cite.

Iain

Stefan Steinegger

unread,
Aug 17, 2009, 4:18:03 AM8/17/09
to Rhino.Mocks
The problem is the following:

You specify Calls the the mock, lets say:
- foo(A)
- foo(B)

You'r application calls actually:
- foo(B)
- foo(C)

so what's actually wrong? If it was a dynamic mock (the common case),
the call foo(C) is allowed. So there is only one call missing, RM says
that the expected call to foo(A) did not happen.

What you probably expect is that RM says that the call to foo had an
argument C instead of A.

I implemented a "AssertArguments" patch, but it never went to the
trunk. You could say, if foo is called, it should assert that the
argument is A. Then RM can tell you that A has been expected and B has
been passed.
Reply all
Reply to author
Forward
0 new messages