Was Re: "stuff", a general request for help, now 'Ideas on correct use of PyUnit in Unit Tests'

Glyph Lefkowitz glyph at twistedmatrix.com
Fri May 12 14:54:38 EDT 2000


Shae Erisson <shapr at uab.edu> writes:

> When I first started writing unit tests I had a very fine granularity, I
> would test each method with lots of input. That doesn't work because I'm
> not testing the 'behaviour,' I'm testing the code...

> If you ascribe to the Extreme Programming methodology, UnitTests come
> from User Stories. User Stories are 'functional requirements' that the
> client has given you. Therefore, I think UnitTests should not test the
> code, they should test that the functional requirements are passed.

Hm.  The problem I guess I'm having is: the "units" in the code do not
always correspond directly to user-specified functionality.  In any
program of a decent size, you're going to have testable, descrete
blocks of logic, which don't have any end-user obviousness.

The problem is, if you construct tests of those behaviors, your unit
tests WILL change behaviors as you refactor, if you end up factoring
out those parts; yet, testing is an important part of the development
process.  Developing tests along with my code has enabled me to
develop some amazingly reliable and small stuff.

So ... is there a need for a different kind of test here?  A
non-"unit" test?  (I.E. "if this fails, it's okay, but make sure to
fix the test to reflect the new behavior" ... just to give a higher
level of granularity and "sureness" when you're testing an
implementation?)  Or am I missing some philosophical point here?

Correction; I am DEFINITELY missing some philosophical point here, I
just want to know which one ;-).

> As the issue of 'how to correctly construct unit tests' is alternately
> clear and confused to me, I would _really_ like to get more feedback
> from other people.

Thanks for your reply; I would like more feedback too.

-- 
                  __________________________________________
                 |    ______      __   __  _____  _     _   |
                 |   |  ____ |      \_/   |_____] |_____|   |
                 |   |_____| |_____  |    |       |     |   |
                 |   @ t w i s t e d m a t r i x  . c o m   |
                 |   http://www.twistedmatrix.com/~glyph/   |
                 `__________________________________________'




More information about the Python-list mailing list