How to have unittest tests to be executed in the order they appear?
tom arnall
kloro2006 at gmail.com
Tue Apr 15 20:27:10 EDT 2008
On Tuesday 15 April 2008 16:23, Ben Finney wrote:
> "Giampaolo Rodola'" <gnewsg at gmail.com> writes:
> > Is there a way to force unittest to run test methods in the order
> > they appear?
>
> No, and this is a good thing.
>
> 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.
>
> Use the TestCase.setUp and TestCase.tearDown methods to handle any
> fixtures needed by test cases in each class of test cases. That way,
> the fixtures will be set up and torn down between every test case.
> Find out about test fixtures in the documentation for unittest
> <URLhttp://www.python.org/doc/lib/module-unittest>.
>
> --
> \ "All my life I've had one dream: to achieve my many goals." -- |
> `\ Homer, _The Simpsons_ |
> _o__) |
> Ben Finney
a better approach maybe is just to write your own test harness. it's trivial
to write a minimal system, which is then a solid basis for the enhancements
which are best for you.
tom arnall
arcata
More information about the Python-list
mailing list