[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: unit test

Ryan Leavengood

5/6/2005 4:23:00 PM

Nathaniel Talbott wrote:
>
> I'd favor the last option, since Ruby's dynamic
> nature makes a method count extremely brittle. Perhaps you could
> explicitly check for methods you expect to be there, or better yet,
> whether the object you're testing #responds_to? the methods of interest?

I agree with this.

Brian: why is it important that you test the number of methods?

Ryan


3 Answers

Austin Ziegler

5/6/2005 4:25:00 PM

0

On 5/6/05, Ryan Leavengood <mrcode@netrox.net> wrote:
> Nathaniel Talbott wrote:
> >
> > I'd favor the last option, since Ruby's dynamic
> > nature makes a method count extremely brittle. Perhaps you could
> > explicitly check for methods you expect to be there, or better yet,
> > whether the object you're testing #responds_to? the methods of interest?
>
> I agree with this.
>
> Brian: why is it important that you test the number of methods?

Thirded. However, if it is important to check the method count, call
#methods with a parameter of +false+. That will only show those
methods that are defined in your class directly.

-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca



Brian Buckley

5/6/2005 4:42:00 PM

0

Nathaniel, Ryan, Austin, Caleb,

The number of methods really wasn't important to me. I was writing lots of
tests to explore the various standard ruby classes ("learning tests") and I
didn't understand what was happening.

Here I've learned in real code I'll think twice before basing any logic on
methods counts because that count is brittle :) Also that unit tests run in
alphabetical order. Thank you for explaining.

Brian

Phlip

5/6/2005 6:02:00 PM

0

Brian Buckley wrote:

> Here I've learned in real code I'll think twice before basing any logic on
> methods counts because that count is brittle :) Also that unit tests run
in
> alphabetical order. Thank you for explaining.

Would it be too late, and too pedantic, to point out one major point of
tests is refactoring, and refactoring will churn the number of methods? So
tests should characterize behavior, not side-effects, and they should not
test method names, method locations, counts, etc?

Probably yes. ;-)

--
Phlip
http://www.c2.com/cgi/wik...