Set up a unit test environment using an UML-editor and ArchGenXML
This How-to applies to: Any version.
Testing...
Since development is going on at many places in the Plone system, it is important to have a way ready to test if the software you wrote is affected by the changes. And, more important the other way around, if your work, in case it makes it way into the Plone core or other add-on products, affects the work of others.
There are several documents available to read on why testing is important, so feel free to have a look:
- Part 15: Unit testing of a great Tutorial
- Part 8: Unit Testing of this one, not less important
- the tutorial Testing in Plone
- and many more. Try the (live) search field in the documentation section typing unit tests or testing
Some of these documents describe in detail how to write the tests itself.
... and ArchGenXML
This document describes the (easy) steps necessary to setup your testing environment when using an UML diagram and ArchGenXML. When generating your projects, you can easily focus on writing them and follow the appropriate tutorials. ArchGenXML is capable of providing a pre-configured testing environment - no more hand-work to create it !
Steps:
- install PloneTestCase product
- create appropriate test package and testcase classes
- assign your project classes to the testcases
PTC - Plone Test Case
PTC is a package to place in your Plone products directory. Its based on Pythons unittest module and adapts its functionality to a Plone system.
For installing the PloneTestCase-0.82 product please refer to its documentation, its not that hard. Extract the archive into the Products directory of you Plone instance and be sure to set your SOFTWARE_HOME and INSTANCE_HOME environment variables correctly. Export them, and use the python interpreter Zope/Plone uses are the important facts. No need to install the product by the product installation screen of Plone! It does not show up anyway :)
UML Testcase Setup
Now on to your diagram:
Create a new package where all the testing stuff goes in. Call it tests and set its stereotype to <<tests>>.
Create a class inside the test package and call it testPlone, set its stereotype to <<plone_testcase>>.
Create an additional class inside the test package, call it testSetup, and give it the stereotype <<setup_testcase>>.
Create a Generalization arrow from testSetup to testPlone.
Now, for every class in your project, create a class inside the test package, named like the class prepended by the literal test. So for a class named MyClass that would be testMyClass. Set its stereotype to <<testcase>>.
Now create a Generalization arrow from every class with stereotype <<testcase>> to the class with the stereotype <<plone_testcase>>.
Create a Realization(abstraction) arrow from every class with stereotype <<testcase>> to the corrsponding class in your project, where it gets the part of its name from - this generates an (empty) test method, named appropriate, for every method in its related project class.
These are the basic steps necessary to get it running.
In case you prefer working with doctests, there is a stereotype <<doc_testcase>> available to generate a skeleton doctest environment.
Save your work, fire up ArchGenXML and inspect the test directory created in your product directory. When you follow the tutorials/documentation about unittesting and such you should now be able to do what is needed to create tests for your project.
Most of the stereotypes and tagged values available are described in detail in the Stereotype and Tagged value overview of the ArchGenXML tutorial.
Its fun and pays in the long run!

Copied to AGX 2.0 manual
http://plone.org/documentation/manual/archgenxml2/stepbystep/unittests/ (unpublished until i checked it with 2.0 )
I gave user td_kuehnel authoring permissions at the new place. Updates over there please