Unit testing JSF based web applications has been considered difficult
because of the constraints of testing JSF components outside the
container. Most of the web-tier testing frameworks follow black-box
testing approach where developers write test classes using the web
components to verify the rendered HTML output is what is expected.
Frameworks such as HtmlUnit, HttpUnit, Canoo WebTest, and Selenium
fall into this category. The limitation of these frameworks is that
they only test the client side of a web application. But this trend
is changing with the recently released JSFUnit and other JSF testing
frameworks such as Shale Test and JSF Extensions that support white-box
testing to test both client and server components of the web application.
And projects like Eclipse Web Tools Platform (WTP) and JXInsight are
also helping in the development and testing of JSF applications...
JSFUnit, which is built on HttpUnit and Apache Cactus, allows integration
testing and debugging of JSF applications and JSF AJAX components. It
can be used for testing both client and server side JSF artifacts in
the same test class. With JSFUnit API, the test class methods can submit
data on a form and verify that managed beans are properly updated.
JSFUnit includes support for RichFaces and Ajax4jsf components. Beta 1
version of this framework was released last month and the second Beta
Version release is scheduled for the end of next month.