当前位置: 首页 > 工具软件 > JSFUnit > 使用案例 >

Testing JSF application with JSFUnit

邬友樵
2023-12-01

People refer JSF as the implementation of this specification - 

a server-side, user-interface, component framework for Java technology based applications.

some implementations:

Apache MyFaces

Sun's Mojarra JFS Reference Implementation


JSFUnit is step on Cactus, means when writing, also need to extend like ServletTestCase, JSFUnit is heavily lie on HtmlUnit, so it can integrate with HtmlUnit to test fron-end.

Basically first create JSFSession, then using it to get JSFServerSession and JSFClientSession. serverSession use to verify Bean Java logic and clientSession can verify html along with HtmlUnit.


public void testCommandButton() throws IOException, SAXException{


        JSFSession jsfSession = new JSFSession("/album_details.jsp");


        JSFServerSession serverSession = jsfSession.getJSFServerSession();
        JSFClientSession clientSession = jsfSession.getJSFClientSession();

        clientSession.click("PurchaseButton");
        Object userBeanValue = serverSession.getManagedBeanValue("#{albumDetailsBean.status}");

        Assert.assertEquals("Successfully purchased:", userBeanValue);

        String spanContent = ((HtmlPage)clientSession.getContentPage()).getElementsByTagName("span").item(0).getTextContent();

        Assert.assertEquals("Successfully purchased:", spanContent);
    }


 类似资料:

相关阅读

相关文章

相关问答