home contents changes options help subscribe edit (external edit)

Unit testing

Unit testing is the process of writing small programs that test the specific functions of small units of the software. These programs are then run to make sure that your changes hasn't broken any functionality. Some philosophies recommend that you write the unit tests before you write the functionality, so called test-driven development.

About unit tests:

Writing unit tests

Some guidance on how to write unit tests.

Test frameworks

When you write unit tests you typically use some sort of testing framework, to make it easier to write and run the tests. The Zope testing framework is based on Python's PyUnit. There are, however, some extended frameworks that you probably want to use to simplify test development:

Note, however, that these frameworks work by putting quite a bit of the real Zope system and/or CMF, Plone, etc. in place for you; therefore, some consider them integration tests (see below) rather than true unit tests.

Pure unit tests should have as few dependencies as possible, and may rely heavily on MockObjects.

Running unit tests

Integration tests

Integration tests are tests which combine various parts of your application and ensure that they work together properly. For example, if you have skin scripts which glue together various CMF tools, then a test of such a script might be considered an integration test.

Integration tests happen at a lower level than functional tests, but a higher level than unit tests.

Resources for integration test:

ZopeTestCase.Functional, http://www.zope.org/Members/shh/ZopeTestCaseWiki/FunctionalTesting

You may find TestLayers a useful technique for complex setup and teardown.

Functional tests

Functional testing is done on the end product (in this case on a web site) usually by recording actions of a user and recording the output of these actions. This recordings can then be replayed by the functional testing software, and the output compared to what should happen.

Resources for functional tests:

  • Tres Seaver's FunctionalTests product provides support for writing functional tests, especially if you use ZEO.
  • Puffin (NB: Puffin hasn't changed for 19 months).
  • [Zope3]:FunctionalTestingFramework

More testing resources:



subject:
  ( 23 subscribers )