cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Fagerstrom <>
Subject Re: Writing tests for Cocoon
Date Thu, 26 Apr 2007 19:21:14 GMT
Grzegorz Kossakowski skrev:
> Hello,
> As latest experiences showed we badly need tests for servlet services. I 
> would like to write some but to be honest I have almost no
> experience with writing automatic tests. I'd be grateful for any 
> pointers, samples, advices etc

The components in the framework can be tested with ordinary junit tests. 
Thanks to dependency injection it is not that hard to create the 
necessary environment. But unit tests will not test the more complicated 
parts of the framework, for that functional tests are needed.

> To be specific I want to know if I can write tests that will run whole 
> Cocoon's instance, execute several servlets (sitemaps) and compare
> resulting XML with static version provided by me.
> I need to do that because I can hardly imagine testing such a core 
> functionality in any other why. Providing mock objects for all
> environment seems to be death-complicated.

Exactly. Actually I tested earlier incarnations of the framework 
following such principles. See

and especially

We didn't find any good way to use the tests when we moved to OSGi 
(today there seem to be much more tools in that area though). And when I 
removed the OSGi stuff I didn't have the energy to set up a new test set.

I used httpunit, but it was fairly painful to get it working the way I 
wanted. Among other things it just swallowed the servlet log. In the end 
it did it work, and it was a great advantage to just be able to run the 
test cases and see that I hadn't broken anything.

A disadvantage is that functional tests take longer time to run than 
ordinary unit tests as one typically need to set up much more environment.

The actual testing was to execute all the URLs in the predecessor to the 
current servlet service samples and check the output.


View raw message