On Thu, 2005-03-10 at 13:28, Luca Morandini wrote: > Ugo Cei wrote: > > > > I used WebTest for a while, but in the end I found that writing tests in > > XML is way too verbose and clumsy. > > I had the same experience... later on I moved to HTMLUnit ([1]), which > offers a lot: > 1) Different browsers emulation. > 2) Retrieving of XML pages as DOM Documents (org.w3c.dom.Document) for > further processing by Java. > 3) Being based on JUnit, the "green bar" works in Eclipse for HTMLUnit > as well. > 4) Calling of Javascript functions embedded in the HTLM page from the > Java test driver. > 5) Availability of Jelly ([2]) as scripting language (well, I opted for > Java, so I cannot comment on this feature). > > But, best of all, it lets you re-create the whole browser environment > within your Java test driver, which, IMO, is better suited for > functional testing than the request/response paradigm of HTTPUnit. > > I was sceptical about using Java for testing, but the Java/JUnit > environment in Eclipse gave me the "quick" feeling of a scripting language.
Thanks for all your comments. I can only fully concur with these statements. I had a go at Canoo Webtest for replacing the Cocoon Anteater tests but shelfed it again quickly. Webtest is very elaborate for testing HTML forms but has no provisions for low-level stuff such as HTTP header checking. Then I tried HtmlUnit, and that looks much better. With a few convenience methods in a common base class, simple test cases can be written in Java just as concise as in Anteater. So I also don't see anymore the added value of writing test in XML. I have now rewritten all existing Anteater tests using HtmlUnit. The last to be done are the WebDAV tests where HtmlUnit falls short for only supporting GET and POST requests. There I'll have to fallback to calling httpclient directly. The most difficult part of the exercise was the integration into the build process. I set it up that HtmlUnit is optional and has to be installed separately (similar to Anteater). If it flies, it should later be integrated, at the expense of a couple of additional jars. I need a bit more time to wrap it all up, and then I'll submit it a patch with the whole stuff. NB the HtmlUnit version of the flowscriptReload test runs without problems whereas the Anteater version shows intermittent failures. Cheers, Alfred.
