Testing in Plone

published Oct 30, 2009

Open space

Testing tutorial: http://plone.org/documentation/tutorial/testing

Look at the tests in Plone itself, or at third party products. Find a product that does something similar and look at its tests.

If a product is not tested at all, a good way to start is add testbrowser tests to just create a content type of that product.

Use pdb in doctests: http://pypi.python.org/pypi/doctestpdbhacks

The p4a packages have good doctests.

The danger of doctests is that you get neither good documentation nor good tests.

Patrick Gerken: Grease monkey script for hiding code examples and showing more links on pypi: http://userscripts.org/scripts/show/50614

The paster templates could add a bit more documentation about how to test.

collective.testcaselayer should help avoid some of the boiler plate code needed.

Hanno created plone.recipe.alltests to run all tests of the packages you selected.

z3c.testsetup should do the same.

You can use nose for tests.

In a pdb in your tests you can start a zope server where you can use your browser to click through the site:

>>> from Testing.ZopeTestCase.utils import startZServer
>>> startZServer()
('', 55143)