[Zope-dev] Unit testing, ZUnit

Dan L. Pierson dan@sol.control.com
24 Oct 2000 11:13:23 -0500


Lalo Martins <lalo@hackandroll.org> writes:

> Then I figured in the long run a Product isn't the best
> sollution; instead, fiddling with App/Product* sounds more like
> it, to allow developers to register tests just like they
> register classes, ZClass superclasses, _misc and help. Of
> course, just like the current registerHelp and others, it
> wouldn't be mandatory and not using it wouldn't break anything.
> 
> Then, in the Product's page in the Control Panel, there would
> be a tab "Test", where you'd be allowed to run the unit tests.

I like the idea a lot, but would like to suggest that unit tests ala
PyUnit really have three parts that call for separate treatment.

1. Test environment setup: construct the data structure(s) a test
needs to run against.  This wants to be separate because different
tests can frequently share the same data structures and data structure
setup can be non-trivial in systems like Zope.  Since Zope is a
persistent object space, there would also need to be code to tear down
a test environment.  Let's just lump that in here since it will be
automagically invoked by the unit test facility.

2. Test definition and execution: pretty obvious :-)

3. Test results reporting: a small number (1?) of standard reporters
plus the ability to define and register new reporters.

Given the above, the task of writing most tests would consist of:

1. Select test environment.

2. Select default reporter.  Optionally list which other reporters can
be selected at test execution time?

3. Write and test the test.

4. Register the test so that it appears on the Test page.

Dan Pierson