This recipe comes to amplify the previous two recipes with more details regarding JSFUnit API. You will see a set of snapshots that cover the main questions about writing JSFUnit test classes.
You can integrate the following code snippets into your JSFUnit test classes just by simple copy-pasting and then replacing the […] sections accordingly to your needs:
WebClientSpec webClientSpec = new WebClientSpec("/[PAGE_NAME]"); HtmlPage htmlPage = (HtmlPage)webClientSpec.doInitialRequest();
FacesContext facesContext = FacesContextBridge.getCurrentInstance();
UIViewRoot uiViewRoot = facesContext.getViewRoot(); ...