Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test JSF application without deploying it in to Server?

Tags:

java

jsf

jsfunit

Hello I've been googling a lot about this. I want to test my JSf application without deploying it in to Server, so basically i want perform mock test like test. I've used JSFUnit before. If its possible with JSFUnit itself, HOW to DO THAT? Is there any other JSF 2.0 testing framework which is simple to use and can simulate container for running tests without container ? [Along with names please provide some tutorial or example references also] Please help!!

like image 528
Kishor Prakash Avatar asked Feb 11 '13 09:02

Kishor Prakash


2 Answers

You could check out the Arquillian Project

You cand find a 1h video tutorial on Testing JSF Applications with Arquillian and Selenium here

like image 148
stacker Avatar answered Oct 13 '22 01:10

stacker


Updated Feb 2018: OpenBrace Limited has closed down, and its ObMimic product is no longer supported.

Although not specifically designed for JSF testing, the ObMimic library of Servlet API test-doubles might be suitable.

It provides plain-Java, out-of-container simulations of Servlet API objects that are accurate enough and configurable enough to be able to run the JSF servlet. This lets you test complete GETs and POSTs of JSF pages without needing to deploy to a server or use a container.

Your tests can create and configure whatever Servlet API objects are necessary for each test (including a ServletContext with any necessary resources, mappings etc), use these to initialise and invoke the JSF servlet to process a request, and then examine the results. Your tests can also install JSF PhaseListeners to access the FacesContext and examine any relevant JSF data structures at appropriate points during the JSF processing.

The ObMimic website and documentation includes a "How to Test JSF Pages" guide that goes into this in some detail, including example code.

Note that as well as testing "real" JSF pages, you can also use this approach with test-specific JSF pages that just invoke or trigger whatever JSF code you are trying to test (i.e. each test can install any desired JSF page text into the ServletContext and then use the JSF servlet to run it).

like image 23
Mike Kaufman Avatar answered Oct 13 '22 01:10

Mike Kaufman