The framework for JUnit and other tests is explained at Cocoon doco:
Testing your Apache Cocoon

Various tests already exist: a number of JUnit tests, some Anteater functional tests, and Catalog Entity Resolver tests. Please add more and contribute patches.

See also the LenyaUnitTests - some ideas could be utilised for the core Cocoon tests.

Anteater tests

How to create new anteater tests

To create a core anteater test, just add a new script under src/test/anteater.

To create tests for a particular block, add anteater scripts under test/anteater in the block source directory (for example: src/blocks/batik/test/anteater/samples-mime-types.xml).

Pages created specifically for core tests should be put in subdirectories under src/webapp/test, see http://localhost:8888/samples/test/ for a list of such pages.

How to run Anteater tests

That's it.

How to run a single Anteater test