unittest: Calling tests in liner number order

Roy Smith roy at panix.com
Sun May 25 10:39:06 EDT 2008


"Diez B. Roggisch" <deets at nospam.web.de> wrote:

> > I agree that tests should not depend on each other, but sometimes it's 
> > still useful to have the tests run in a certain order for reporting 
> > purposes.
> 
> Then sort your report. Seriously. A test-outpt shoud be in a way that 
> delimits individual testresults in a way that makes them easily 
> extractable. Then if you want them to be ordered for e.g. diff'ing - 
> sort them.
> 
> Diez

Here's an example of why *running* tests in order can make sense.

You could have a bunch of tests of increasing complexity.  The first bunch 
of tests all run in a few seconds and test some basic functionality.  From 
experience, you also know that these are the tests that are most likely to 
fail as you port to a new environment.

There's also some tests which take a long time to run.  If the basic stuff 
that's being tested by the earlier tests doesn't work, there's no way these 
tests could pass, but they still take a long time to fail.

It's really handy to have the simple tests RUN first.  If you see they 
fail, you can cancel the rest of the test run and get on with fixing your 
code faster.

It's a good thing to make it easy to do things the right way, and difficult 
to do things the wrong way.  The danger is when you let your pre-conceived 
notions of right and wrong trick you into making it difficult to do things 
any way but YOUR way.

So far, the strongest argument I've seen against the OP's idea is that it's 
not portable to Iron Python.  That's a legitimate argument.  All the rest 
of the "You're not supposed to do it that way" arguments are just religion.



More information about the Python-list mailing list