webtier@glassfish.java.net

Re: [webtier] How to test JSF 2.0 apps?

From: Edward Burns <edward.burns_at_oracle.com>
Date: Tue, 11 May 2010 01:08:58 +0200

On 5/5/10 11:50 , webtier_at_javadesktop.org wrote:
> One of the most crucial points when developing enterprise systems is [b]testing[/b], both on unit as well as on integration level.
> Once the system starts to grow beyond a trivial level of complexity, it's [i]mandatory[/i] to have such tests that can be integrated in a automated continuous integration system (Hudson or the likes).
>
> While this topic is pretty well covered for EJB 3.1 components, support for automated testing the web part seems to be still marginal in the JEE universe (in contrast, for instance, to the Ruby on Rails or Spring MVC worlds, where testability might almost be considered as an in-built design pattern).
>
> In particular when it comes to JSF 2.0, I'm still searching for a decent, easy-to-use and effcient way to implement automated unit and integration tests for my the Faces part of my JEE 6 applications.
> There's JSFUnit (http://www.jboss.org/jsfunit) - yet, it appears to require the application already deployed in a container (correct me if I'm wrong), which introduces quite some (unneccessary?) complexity and inefficiency into the test setup and execution process.
> There's also Arquillian (http://community.jboss.org/docs/DOC-14376) for which I still have to find out whether it is meant or useful for JSF tests.

Andreas Hartmann wrote:

AH> Testing has been made as a part of the architecture requirements for
AH> our Applications. We use a modified Version of Folwers "Passive View
AH> Pattern" [http://www.martinfowler.com/eaaDev/PassiveScreen.html] and
AH> the Spring EL-Resolver instead of the JSF Standard EL-Resolver.

AH> With this general foundation we can easily inject Mock Objects of
AH> our Business Services that are called from the JSF Application. So
AH> we are able to Test the logic to call and process a Business Service
AH> from the JSF Application without a running Business Service and we
AH> don't need a Webcontainer for our tests.

AH> We prefer at the moment the XML based configuration and test these
AH> with the Static Analysis Feature of JSFUnit
AH> [http://community.jboss.org/wiki/StaticAnalysis].

AH> Also these tests run perfectly with a continuous integration tool for
AH> JSF 1.2 and JSF 2.0 and are ready for regression tests out of the
AH> box.

AH> For testing the JSF pages it is necessary to deploy the
AH> application. Here we use WebDriver
AH> [http://code.google.com/p/selenium/], maybe in conjunction with
AH> Selenium.

AH> WebDriver operate with native Browser Support and it works really
AH> fine with any JSF Ajax Component Library. You are able to integrate
AH> the WebDriver Test also with in a continuous integration tool but in
AH> this case you must have a look at your test data and maybe prepare
AH> them before executing the tests.