Re: Are Tests First Class Clients?
Posted: Jan 27, 2005 1:39 PM
verify() methods are equivalent to
get methods, in that they expose data for
> comparison, so I recommend going one step further:
equals() to compare
Merger instances by their current state. This
> way, your tests can simply use
> to compare expected state with actual state, without
> exposing the internals of that state.
verify methods don't expose data for comparison. They use the private data and either return quietly or throw a
I considered the
equals approach you suggest, and it is a good suggestion. But the reason I didn't go that way is that I wanted more information passed to
TestFailedException than just the contents of the
Mergers are different. I want to find out how they are different.
> This might seem strange, since the class name is
Merger. A verb-named class implementing
equals()? Well, I don't like verb-named
> classes, because those are generally procedures, rather
> than objects. If procedural code is appropriate here, then
> I'd expect a design like this:
MergeResult result = merger.merge(templateName,
result contains the string-based output
> along with any metadata describing the rendered page. (If
> there is none, then maybe
MergeResult is just
Actually, "Merger" is a noun. It usually means two companies companies joining forces, so it doesn't quite fit here, but it is catchy and distinctive and seems to serve us well in discussions. The verb "merge" is the name of one of its methods.