You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by do...@cocoon.apache.org on 2004/10/13 13:13:50 UTC
[Cocoon Wiki] New: UnitTestingStylesheetsAndPipelines
Date: 2004-10-13T04:13:50
Editor: NicoVerwer <nv...@email.com>
Wiki: Cocoon Wiki
Page: UnitTestingStylesheetsAndPipelines
URL: http://wiki.apache.org/cocoon/UnitTestingStylesheetsAndPipelines
Started the page
New Page:
== Unit-tests for stylesheets and pipelines. ==
Unit and regression testing is a best practice of software engineering.
If you don't know about unit testing and test-driven development, please have a look at these excellent websites:
* [http://www.junit.org/index.htm JUnit.org]
* [http://www.testdriven.com/ TestDriven.com]
* [http://www.objectmentor.com/writeUps/TestDrivenDevelopment Object Mentor]
There are several tools available that will help you to do unit and regression testing, integration testing and acceptance testing on your Cocoon applications.
For example, you can and should use
* [http://www.junit.org/index.htm JUnit] for Java components.
* [http://www.httpunit.org/ HttpUnit] for testing your application 'from the outside'.
* [http://aft.sourceforge.net/ Anteater] for automating functional tests.
However, until now there was no framework for testing stylesheets and Cocoon pipelines, which are at the core of many Cocoon applications.
For my work on several projects using Cocoon I needed such a framework, and decided that it shouldn't be too hard to build one.
The result is Co``Unit (names like CUnit and CCUnit were already taken), which offers a simple framework for unit tests, complementary to other tools (like JUnit and Http``Unit).
=== Installing ===
Temporarily, the code for Co``Unit is attached to this page, until it finds its way to a better place.
To use Co``Unit you need Cocoon 2.1.6 (which does not exist at the time of writing), or a version from the repository after 11 October 2004.
On that date, a bug in the MountTableTransformer was fixed, which is essential to the unit-test framework.
If you get a Null``Pointer``Exception trying to run unit tests, you need to update Cocoon, or at least the MountTableTransformer.
Installing the framework code is simple: Just unpack it at a convenient place, like in a sub-directory of the directory where you put all your Cocoon projects.
For example, if your Cocoon projects are in /home/user/cocoon-projects, create a sub-directory called unit-test, and unpack in that directory.
CoUnit is typically mounted from the main sitemap, or from the main mount-table.
* from the main sitemap:
{{{
<map:match pattern="test/**">
<map:mount check-reload="yes" src="/path/to/unit-test/framework/" uri-prefix="test"/>
</map:match>
}}}
* from mount-table.xml:
{{{
<mount uri-prefix="test" src="/path/to/unit-test/framework/"/>
}}}
If you plan to run unit tests for the framework itself (which I am busy adding!), use the mount-table, because all testable components need to be mounted that way.
=== Miscellaneous ===
If you are interested in using Co``Unit, it is a good idea to look at my presentation at the Cocoon Get``Together 2004.
You are invited to play around with the code and improve it!
Of course, you can also add things to this Wiki page.
Please send me an email (nverwer at be-value-nl, if you add to this page I will get notified) if you have added something that might be of interest to others, so I can keep a 'complete' version until there is a better way (like svn) to collaborate.