Updated February 2018: OpenBrace Limited closed and its ObMimic product is no longer supported.
Although this is not specifically designed for JSF testing, the ObMimic library in two instances of the Servlet API may be appropriate.
It provides simple, container-free Java solutions for Servlet API objects that are accurate enough and configurable enough to be able to run the JSF servlet. This allows you to test full GET and POST files on JSF pages without the need to deploy to a server or use a container.
Your tests can create and configure any Servlet API objects for each test (including ServletContext with any necessary resources, mappings, etc.), use them to initialize and call the JSF servlet to process the request, and then to examine the results, your tests also can set JSF PhaseListeners to access the FacesContext and examine any relevant JSF data structures at appropriate points during JSF processing.
The ObMimic website and documentation includes How to Test JSF Pages , which is covered in detail in this, including sample code.
Please note that, as well as testing "real" JSF pages, you can also use this approach with specific JSF pages for testing, which simply call or run any JSF code that you are trying to test (i.e. each test can install any the desired JSF text page in ServletContext, then use the JSF servlet to run it).
source share