The SchoolTool test runner has a couple of features that the Zope 3 test runner does not have.
- When an error occurs while rendering a Zope Page Template, the SchoolTool test runner can show you the location in the template as well as the relevant TALES expression in the traceback.
- You can instruct the SchoolTool test runner to limit recursive directory tree walks to a subdirectory in your source three -- this shaves off whooping 6 seconds when you want to test a single Zope 3 package. (This is very important when running a small subset of unit tests that take e.g. 2 to 6 seconds to run, when you want to have a quick change - run tests - fix cycle.)
- The SchoolTool test runner can warn you if you have test classes that are not included in the test suite.
Here's how you can use it for a Zope 3 package called "ivija" (which happens to be a Zope 3 based application that I'm currently working on):
- Download test.py and save it as
st-test.py
. Place or symlink it into your Zope 3 root directory (~/Zope3 in my case). - Create a shell script called
test
and put it wherever you want it (I keep it in ~/Zope3/src/ivija):#!/bin/sh ZOPE3_HOME=$HOME/Zope3 TEST=$ZOPE3_HOME/st-test.py cd $ZOPE3_HOME python2.3 $TEST -wpv --search-in src/ivija "$@"
- When you want to run the tests, just run them as
./test [options]
.
Here's how long the Zope 3 test runner takes to walk through all subdirectories and find out which test modules need to be imported:
mg: ~/ivija$ time ./test.py nosuchtest Configuration file found. Running UNIT tests from /home/mg/Zope3 not a package src/ivija/reportgen/zLOG/tests not a package src/ivija/reportgen/StructuredText/tests No unit tests to be run. Running FUNCTIONAL tests from /home/mg/Zope3 No functional tests to be run. real 0m8.438s user 0m7.050s sys 0m1.290s
Here's how long the SchoolTool test runner takes to walk through just the ivija package subdirectories:
mg: ~/ivija$ time ./test nosuchtest /home/mg/Zope3/src/ivija/reportgen/zLOG/tests is not a package /home/mg/Zope3/src/ivija/reportgen/StructuredText/tests is not a package ---------------------------------------------------------------------- Ran 0 tests in 0.000s OK real 0m0.338s user 0m0.200s sys 0m0.010s
Not bad, huh?
Update: The SchoolTool test runner is no longer maintained. In the meantime the Zope 3 test runner gained a lot of features not present in the SchoolTool test runner.