Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #97964

Unittests and serial workflows

From Fabien <fabien.maussion@gmail.com>
Newsgroups comp.lang.python
Subject Unittests and serial workflows
Date 2015-10-27 05:10 +0100
Organization Aioe.org NNTP Server
Message-ID <n0mtgj$dag$1@speranza.aioe.org> (permalink)

Show all headers | View raw


Hi all,

I am not trained as a software developer and have only superficial 
knowledge about the theories and good practices of software testing.

Say I have several tasks (functions) A(), B(), C(), etc., each of them 
depending on the previous one. My understanding of unit testing is that 
each function should be tested alone and each test should be 
independent, so that currently my tests look like this:

class TestTasks(unittest.TestCase):

     def test_a(self):
         out = A()
         self.assertStuffs(out)

     def test_b(self):
         tmp = A()
         out = B(tmp)
         self.assertStuffs(out)

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).

Furthermore, it is inefficient since task A() is going to be run many 
times. Of course I could run all the tasks once, store the results and 
run my tests afterwards one by one but this contradicts somehow the idea 
of unit testing. And I like to be able to run each test alone (in 
PyCharm a mouse click alone starts a single test).

My question(s): is Unittest the "right" framework for my needs? Should I 
move to Nosetests? Any hint to a useful, not too long document about 
testing framework and good practices?

Thanks a lot,

Fabien



Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Unittests and serial workflows Fabien <fabien.maussion@gmail.com> - 2015-10-27 05:10 +0100
  Re: Unittests and serial workflows Paul Rubin <no.email@nospam.invalid> - 2015-10-26 23:18 -0700
    Re: Unittests and serial workflows Fabien <fabien.maussion@gmail.com> - 2015-10-30 16:05 +0100
      Re: Unittests and serial workflows Paul Rubin <no.email@nospam.invalid> - 2015-10-30 09:23 -0700
  Re: Unittests and serial workflows Steven D'Aprano <steve@pearwood.info> - 2015-10-31 12:28 +1100

csiph-web