----- Original Message ----- 
From: "Nathaniel Talbott" <nathaniel / talbott.ws>
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Wednesday, July 16, 2003 3:58 PM
Subject: Re: Test::Unit no tests specified


> > I know I could redesign my stuff to not use inheritence here, but I'd
> > prefer to only see a failure raised if I have an empty test:
> >
> >   class MyTestCase < ...
> >     def test_this
> >     end
> >   end
>
> Well, I don't think this is possible (although I know someone will prove
me
> wrong as soon as I say that). How can one know if a method is empty?
There's
> no way I know of to determine it without walking the AST (which would
> definitely fall under non-trivial).

If you define emptiness as not asserting anything in the method, you could
do above mentioned by resetting a flag (TestCase instance variable) before
calling a test method and check it after the method returns. Asserts would
set this flag and if the flag is not set it would mean that no assert had
been called.

Gennady.