Menu

#2 Surfacing references

open
None
5
2006-02-21
2006-02-21
No

rMock uses references behind the scenes. References is
what makes rMock able to transparently describe and
compare different objects without knowing about the
object. For instance an Array is checked for equality
the same way a String is the only difference is that an
array is passed as an ArrayReference. This happens
behind the scenes today.

I propose that we make it possible to explicitly pass a
Reference to an expression. That would enable a
developer to just create a special kind of reference
for a new need.

As an example the is.clazz.name(is.eq("MyObject"))
construction that is now implemented as a custom
constraint would be expressed like this now using the
references approach:

is.eq(by.className("MyObject"));

if you want to check that an exception is thrown and
wnat to know something about the message you would do
something like this:

expectThatExceptionThrown(is.instaceOf(RuntimeException.class).and(is.containing(by.exception.message("interesting
text"));

This can probably be "prettified" but this should givev
some idea what I'm after.

Discussion


Log in to post a comment.