Re: How to have unittest tests to be executed in the order they appear?
- From: Ben Finney <bignose+hates-spam@xxxxxxxxxxxxxxx>
- Date: Thu, 17 Apr 2008 08:29:48 +1000
Matthew Woodcraft <mattheww@xxxxxxxxxxxxxxxxxxxxxx> writes:
Ben Finney <bignose+hates-spam@xxxxxxxxxxxxxxx> wrote:
Your test cases should *not* depend on any state from other test
cases; they should function equally well when executed in any
arbitrary sequence. Dependencies between separate test cases (e.g.
"they only work correctly when run in a specific sequence") means
you're not isolating them properly.
So a mode to randomise the test sequence would be nice to have.
Twisted has a "trial" framework that allows just such a mode
<URL:http://buildbot.net/repos/release/docs/reference/buildbot.steps.python_twisted.Trial-class.html>.
Unittest's behaviour (using alphabetical order) doesn't really help
to detect undesired dependencies (which might be bugs in the test
suite or bugs in the underlying code).
Agreed. It's just a matter of making a custom unittest.TestRunner,
though. Yes, a Small Matter of Programming which I haven't actually
done, but unittest doesn't make it difficult to do that.
But running tests in the order they appear is often helpful: you can
put the tests for basic stuff before the tests for advanced stuff,
and then if you suddenly get seventeen failing tests, you know that
the first failure is the best bet to investigate first.
Surely, since "suddenly" implies you changed one small area of the
code, that area of the code is the best place to look for what caused
the failure.
--
\ "I planted some bird seed. A bird came up. Now I don't know |
`\ what to feed it." -- Steven Wright |
_o__) |
Ben Finney
.
- Follow-Ups:
- Re: How to have unittest tests to be executed in the order they appear?
- From: Roy Smith
- Re: How to have unittest tests to be executed in the order they appear?
- From: Matthew Woodcraft
- Re: How to have unittest tests to be executed in the order they appear?
- References:
- How to have unittest tests to be executed in the order they appear?
- From: Giampaolo Rodola'
- Re: How to have unittest tests to be executed in the order they appear?
- From: Ben Finney
- Re: How to have unittest tests to be executed in the order they appear?
- From: Matthew Woodcraft
- How to have unittest tests to be executed in the order they appear?
- Prev by Date: Re: Profiling, recursive func slower than imperative, normal?
- Next by Date: Re: def power, problem when raising power to decimals
- Previous by thread: Re: How to have unittest tests to be executed in the order they appear?
- Next by thread: Re: How to have unittest tests to be executed in the order they appear?
- Index(es):
Relevant Pages
|