[TIP] alphabetical order in testing

Olemis Lang olemis at gmail.com
Wed Jan 20 06:57:20 PST 2010


On Wed, Jan 20, 2010 at 9:27 AM, Alfredo Deza <alfredodeza at gmail.com> wrote:
>
> On Wed, Jan 20, 2010 at 9:12 AM, Olemis Lang <olemis at gmail.com> wrote:
>>
>> On Wed, Jan 20, 2010 at 5:42 AM, holger krekel <holger at merlinux.eu> wrote:
>> > On Tue, Jan 19, 2010 at 15:35 -0500, Olemis Lang wrote:
>> >> On Tue, Jan 19, 2010 at 3:26 PM, Alfredo Deza <alfredodeza at gmail.com>
>> >> wrote:
>> >> > Hi
>> >> >
>> >> > I am aware that test methods are executed in alphabetical order.
>> >> >
>> >> > What would be the ideal/preferable way of dealing with methods that
>> >> > depend
>> >> > in the order they are being executed?
>> >> >
>> >> > Given that:
>> >> >
>> >> >> class TestFiles(unittest.TestCase):
>> >> >>
>> >> >>     def test_second_file(self):
>> >> >>         """I depend on z_file"""
>> >> >>
>> >> >>     def test_z_file(self):
>> >> >>         """I should run before second_file"""
>> >> >
>> >> >
>> >> > Would it be OK to alter the naming in the methods to make sure they
>> >> > are run
>> >> > in the order I need to? Even if the naming gets really weird like:
>> >> >
>> >>
>> >> Very bad practice ! Dependencies between test cases can lead to
>> >> fragile tests . TCs should be as isolated as possible
>> >> ;o)
>> >
>> > Some way of telling a test runner to consider tests in a certain
>> > order makes sense to me, though.
>
> Can someone give me a good explanation *why* test methods are executed
> alphabetically  rather than the normal
> Python way (top down). ?
>

So that you can find it more easily in the test report . D'u prefer
random output and follow the order of the Py dicts when you wanna know
what happened with your test cases ? If so, pls, file a request for
enhancement in the Py-dev tracker (pls guys HELP !, provide a link for
that)

-- 
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
New! Writing doctests for Trac plugins WAS: [Trac] Re: Writing ...  -
http://feedproxy.google.com/~r/TracGViz-full/~3/_wCvZJTu--s/msg00152.html



More information about the testing-in-python mailing list