views:

208

answers:

4

What kind of tools or techniques exist for this purpose?

+2  A: 

Check out HtmlUnit or Watij.

They provide a headless-browser mechanism that allows you to write tests by navigating HTML pages, filling in forms, pressing buttons etc.

Having said that, I try to put as little functionality in my JSPs (or similar) as possible, and focus my testing on the underlying business logic objects and their creation of beans for JSP display. But final testing of the JSPs is definitely a good idea.

Brian Agnew
A: 

Strip it out? ;)

In Container testing (using say Cactus) or compile the JSPs to servlets and then mock in the response/reply objects.

JUnit In Action has a section of unit testing JSPs & server side code. I would highly recommend the book.

mlk
+3  A: 

Other than display logic, which is notoriously hard to test, my advice would be don't put logic in JSPs. Instead move it into POJOs and it's problem solved.

Nick Holt
+1  A: 

Try JspTest. Use it for testing the view logic in a JSP page.

Martin OConnor