Morris, Chris [mailto:chris.morris / snelling.com] wrote:

> I'm just starting to use testunit instead of rubyunit ... I 
> noticed with an existing RUNIT::TestCase, when I changed it 
> over to Test::Unit::TestCase, setup wasn't called, it's now 
> set_up. Why the change and can testunit alias setup to set_up? 

To answer the first question, Test::Unit uses #set_up because it's
proper grammar. "Setup" is only one word if it is used as a noun, and
within the context of a testing framework, we use "set up" as a verb,
i.e. "Set up the test now."

To answer the second question, I'm of a divided mind on aliasing. On the
one hand, I like the idea of having very consistent naming for all
tests. It's easier for me to read other people's tests when they use the
same names as all the other tests I read. It's also much easier to do
programmatic processing on a set of tests if there are not aliased
methods that have to be dealt with in their various forms (i.e. if an
extension writer wants to grab every set up method, it's a pain for him
to have to deal with both #set_up and #setup).

On the other hand, I'd like the framework to obey POLS, and there are
things that some people expect, such as #assert_equals instead of
#assert_equal and #setup instead of #set_up. I will say that it seems
much of the surprise that's occurring (with these two names in
particular) has more to do with people being used to doing surprising
things than it does with people naturally gravitating towards those
things. Expectations have been redefined for some subset of the users,
and thus they go "Oh!" when it doesn't work how they've come to expect.

For #assert_equals, my current plan is to _not_ alias (I know you didn't
ask, but I've been asked this several times privately, so I thought I'd
answer it in public while I'm on this topic). If you use the wrong name,
it will cause an error, and you'll have to fix it. To fix it, a simple
search and replace suffices. The advantage of aliasing in this case does
not seem to outweight the disadvantages.

For #setup, there is another issue: it fails silently. I've converted
code from Lapidary to Test::Unit several times and had it suddenly stop
working. Aack! What's wrong? Oh, I forgot to rename #setup to #set_up.
This is dangerous and just plain aggravating. There are two solutions.
One is to issue a warning if you have a method named #setup. Another is
to alias #setup to #set_up (actually it's not as simple as aliasing,
which is part of why I don't like this option, but I can do it).

Thoughts?


Nathaniel

<:((><
+ - -
| RoleModel Software, Inc.
| EQUIP VI