Help

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

SeamTest bootstraps the JSF life cycle and runs outside the container (though still bootstraps JBoss Embedded to leverage Java EE services) whereas JSFUnit runs against an application deployed to a container.

SeamTest...

  • can arguably execute faster that JSFUnit (though this may change)
  • is good at doing low-level integration tests without a fully-functioning application
  • provides a way to unit test JSF (since bootrapping JSF is a pain)

JSFUnit...

  • is a truer execution environment
  • can validate the encoded output of the JSF component tree
  • supports any AS
  • is closer to a functional/acceptance testing tool

Although the project is still fairly green, you might want to check out FacesTester if you're interested in unit testing JSF without a container (embedded or otherwise).

One of the advantages JSFUnit has over SeamTest at the moment is that JSFUnit works with minimal headache and setup, whereas SeamTest has been plagued by the complexity of properly setting up JBoss Embedded. In particular, it's tough to get SeamTest to execute in the IDE since JBoss Embedded requires a separate set of JARs from the application, leading to classpath conflicts.

If you are interested in using SeamTest with minimal struggle, you are recommended to start your project with seam-gen and execute the tests using the Ant build. People have been successful getting SeamTest to work in a Maven 2 environment, though.

SeamTest also has the advantage of testing your components without interference from the UI (which may or may not be a good thing, depends on who you ask) using the ComponentTest. Also SeamTest assumes / requires at least an intermediate level of JSF knowledge and understanding of the life cycle so as to know which functions to override to properly execute your application and tests. While probably not a bad thing to really understand JSF it is another barrier of entry for truly understanding SeamTest.

One of the advantages currently of JSFUnit is its level of documentation. Sadly SeamTest isn't very well documented (which I'm working on fixing. Think man page level documentation, watch for it) unless you look at the code; mostly because the great documentation about how to use it and what to override is on the Request class which is omitted from the Javadocs because of it's visibility. JSFUnit also will let you see how well your AJAX is working (which may or may not work correctly with SeamTest due to mocks and stubs). While I haven't had time to test, JSFUnit should be able to run inside JBoss Embedded (you'd probably have to include the JSF jars though) which would be very useful for Seam testing in a slimmed down container, and run along side your SeamTests.

Other tools to bring into the testing mix are products like like Selenium and WATIR/J. These work very nice in place of JSFUnit but they can not be run as easily in a headless environment whereas JSFUnit works just fine because it doesn't require a browser. As Dan mentioned you can verify the component tree with JSFUnit, and actually anything about the JSF life cycle. Where with these other two you simply get the HTML generated from JSF.

I really see all of these tools as very valued pieces in our toolbox to use when the situation requires.