[TIP] [pytesting] How to begin

Grig Gheorghiu grig at gheorghiu.net
Wed Feb 28 11:29:55 PST 2007


--- simon stockes <simonstockes at gmail.com> wrote:

> I want to start my new project in using unittest methodology.
> My software will be a desktop application using PyQt.

OK, first off, here are some PyQt-related testing tools:

qunittest:

http://projects.edgewall.com/qunittest/

pyGuiUnit:

http://sourceforge.net/projects/pyguiunit/

(these and many more are categorized on the Python Testing Tools
Taxonomy wiki at
<http://pycheesecake.org/wiki/PythonTestingToolsTaxonomy>)

> 
> To do it I would like to know certains things:
> Should I write a test for each method or function i will write ?

That would be your best bet. That's what unit testing is all about. But
you shouldn't stop there; you need to write functional and system
integration tests too, that exercise multiple paths through your
application. Basically you need to look at your application both from
the inside out (unit testing) and from the outside in
(functional/system/integration testing).


> 
> How to organize the tests in the software architecture ?

See above. Another important thing to remember is that once you have
automated tests of any kind, you need to set up a continuous
integration system (such as buildbot) that runs your tests
periodically, using the very latest version of your source code, and
that notifies you on failures.


> 
> Is there better unittest modules than others ?

You can use either nose or py.test. 

nose:

http://somethingaboutorange.com/mrl/projects/nose/

py.test:

http://codespeak.net/py/current/doc/test.html

Titus spoke quite extensively about nose in our tutorial at Pycon. 

Here are some more links worth checking out:

http://code.google.com/p/python-nose/wiki/RecentArticles

Grig



More information about the testing-in-python mailing list