Version 9

    A JSFUnit Test Class is an ordinary JUnit class.  However, if you are using Cactus instead of Arquillian, it does need to extend org.apache.cactus.ServletTestCase which extends junit.framework.TestCase.  Also, you are limited to using JUnit 3.  If you need JUnit 4 then you must use Arquillian.


    Here is a simple example:

    import java.io.IOException;
    import org.jboss.jsfunit.jsfsession.JSFClientSession;
    import org.jboss.jsfunit.jsfsession.JSFServerSession;
    import org.jboss.jsfunit.jsfsession.JSFSession;
    public class MyJSFUnitTest extends ServletTestCase
       private JSFClientSession client;
       private JSFServerSession server;
       // JUnit suite() method
       public static Test suite()
          return new TestSuite( MyJSFUnitTest.class );
       // optional JUnit setUp() method
       public void setUp() throws IOException
          // Initial JSF request
          JSFSession jsfSession = new JSFSession("/hello.jsf");
          this.client = jsfSession.getJSFClientSession();
          this.server = jsfSession.getJSFServerSession();
       // one or more JUnit test methods
       public void testHelloWorld() throws IOException
          client.setValue("name", "Stan");
          assertEquals("Stan", server.getManagedBeanValue("#{myBean.name}"));
          assertTrue(client.getPageAsText().contains("Hello, Stan"));