FacesTester
Try it out. Give us feedback. Make it (and your app) better 8-)
FacesTester is a JSF unit testing framework which allows you to exercise your JavaServer Faces application (managed beans, UIComponents, PhaseListeners, etc) outside a container. This allows for faster testing, as well simplifying testing in a continuous integration environment.
- 1 FacesTester
- 1.1 Dependencies
- 1.2 Usage
- 1.3 Injection
- 1.4 Obtaining FacesTester
- 1.5 JavaDoc
Dependencies
The dependencies for FacesTester are little more than what your application already has. Specifically, here are the classes that you likely will not already have in your project:
- Spring Mock 2.0.8 (dependency removed in version 0.3.0)
- Java Persistence API 1.0 (optional)
Usage
Using FacesTester is pretty straightforward. This example is taken from one of FacesTester's own integration tests:
The basic Object is FacesTester. Using that object, we can request pages, retrieve specific components, etc. FacesTester configures itself based on the web.xml in your project, as well as any faces-config.xml files it may find. The web descriptor is located using a simple searching algorithm in several possible locations for a Maven-based project. If you are not using Maven, or the file is an unusual location, you can specify the location of the descriptor file by using the facestester.webAppPath system property.
Injection
One of the hard parts about testing JSF applications is the heavy use of injection. FacesTester provides a facility for performing injection implicitly, using pre-registered, arbitrary objects. For example, for this managed bean:
the unit test might look like this:
Obtaining FacesTester
For Maven users, the following dependency in your pom.xml will be sufficient:
For non-Maven users (and non-Ivy users), the jar file can be downloaded from the java.net Maven repository, or from the download section here on the project site.
JavaDoc
The JavaDocs for the current release can be found at steeplesoft.com.





