Since CMF 2.0 I did a lot of test refactoring, changing the ways CMF tests are set up. Goal was to use more generic and up to date testing patterns, making it easier to write new tests.

Here is an overview what changed:


All tests that depend on a running Zope application use now ZopeTestCase's ZopeLite app. It is not compatible with Zope2.app(), so don't use Zope2.app() anymore. ZopeLite doesn't start up Products by default, you have to specify required Products explicitly using ZopeTestCase.installProduct(). Not each Product has to be initialized that way. Don't initialize Five that way - ZCML is set up differently.


ZCML is set up using test layers. Their setUp() and tearDown() methods are only run once for all tests in the layer.

Functional Tests

For functional tests that depend on a complete CMF site, you can use the FunctionalLayers defined in the testing modules. They have to be used with ZopeTestCase's FunctionalTestCase or FunctionalDocFileSuite test cases. This makes sure each test gets its own DemoStorage sandbox. You can commit changes to the site and don't have to care about the teardown.

It is now easy to set up zope.testbrowser based tests. See CMFCalendar.browser.tests for an example.

See also http://plone.org/documentation/tutorial/testing/functional-tests

Using Testrecorder

You can use zope.testrecorder for creating the testbrowser tests. To make sure you have the same setup as the tests and to enforce test translations, you can replace your etc/site.zcml by this::

<configure xmlns="http://namespaces.zope.org/zope";>
  <include package="Products.CMFDefault"/>
  <include package="Products.CMFTopic"/>
  <include package="Products.DCWorkflow"/>
  <include package="Products.CMFCalendar"/>

Set up a site called 'site' and start recording.

See also http://plone.org/documentation/tutorial/testing/zope-testrecorder

Any questions or comments are welcome.



Zope-CMF maillist  -  Zope-CMF@lists.zope.org

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to