Unittests and serial workflows

Chris Angelico rosuav at gmail.com
Fri Oct 30 21:46:53 EDT 2015


On Sat, Oct 31, 2015 at 12:28 PM, Steven D'Aprano <steve at pearwood.info> wrote:
>> And so forth. The order in which unittest is running the test is not the
>> one given by the code (it seems to be alphabetical?) so that I am not
>> guaranteed that my functions are tested in the right order (my real
>> tasks of course are not sorted alphabetically).
>
> In my opinion, if your unit tests need to be run in a specific order, they
> aren't sufficiently isolated. But, I accept that sometimes reality bites,
> and you have to deal with tests which aren't sufficiently isolated. You
> don't have time to fix the tests, and you can't fix the code you're
> testing. Sucks to be you...

If the order of test execution affects the overall pass/fail of the
test set, then yes, that's a problem. But if, as in the OP's example,
some tests assume the correct operation of features tested
individually elsewhere, it would be kinda nice to say "do these
low-level tests first, and if they pass, go on to test these
higher-level features". Is there a way to express that in unittest?

ChrisA



More information about the Python-list mailing list