JSF Test Tool

Source: Internet
Author: User

Http://developer.51cto.com

 

JSF Test Tool

Testing JSF components outside the container is limited, so we always think that unit testing for JSF applications is difficult. Most web layer testing frameworks follow the black box testing method.
Compile a test class for the Web component to verify that the rendered HTML output meets expectations. Htmlunit, httpunit, canoo
Both the webtest and selenium frameworks belong to this type. The limitations of these frameworks are that they can only test the web application client.

However, this phenomenon has been followed by the recently released jsfunit and some other JSF testing frameworks, such as shale test and JSF.
Extensions and changed. These testing frameworks support white-box testing of Web application client and server components. In addition, some projects, such as Eclipse Web
Tools platform (WTP) and jxinsight have begun to assist in the development and testing of JSF applications.

Like other unit test frameworks, a typical JSF test framework requires the following features:
◆ A test case can be run independently outside the container, and a test case can be run from an IDE similar to eclipse or netbeans to promote test-driven development (TDD ).
◆ Test the complete HTTP request-response lifecycle.
◆ Integration with build tools such as ant or Maven to run unit tests in an automatic build and continuous integration environment.

The JSF test framework also needs to support specific requirements of JSF, such:
◆ Call the jsf api in the test method, instead of checking the HTML output or client DOM object.
◆ Test by verifying that the user inputs the form and accesses the correct page view.
◆ Verify whether the action is executed as expected and whether the expected error message is displayed.
◆ The JSF component can be verified even if the rendered attribute is set to false (the component is not rendered on the web browser but is still saved on the server.
◆ Verify that the xml configuration file (faces-config.xml, etc.) is correctly loaded.

Test Framework

Jsfunit is built on httpunit and Apache cactus, allowing JSF applications and JSF
Comprehensive Test and debugging of Ajax components. It can test the client and server of the JSF product in the same test class. With jsfunit
API, test method can submit form data, and verify that the managed bean is correctly updated.

Jsfunit includes a JSF static analysis test suite to verify the JSF configuration file to ensure that any configuration-related issues can be identified before a problem occurs at runtime. It also provides
Jsftimer component to perform Performance Analysis of JSF lifecycle. It can be used to track the response time of each stage of the JSF lifecycle for a specified Web request and assert the response time.
Within the SLA limit.

Jsfunit supports richfaces and ajax4jsf components. The Beta 1 version of this framework was released last month, and the second beta version is planned to be released by the end of next month.

Shale
As an Apache project, the testing framework provides mock object implementation for servlet and JSF components. These basic test classes can be used to test the shale framework class and build on this
The JSF application component on the framework. The shale test can be used to write an independent unit test to run viewcontroller.
Method exposed by the API. Shale testing is useful because it is complicated to build a runtime environment for a viewcontroller component. The following are the main types of shale testing frameworks:
◆ Abstractjsftestcase: this is a basic test class for testing the servlet and JSF components of a Web application.
◆ Abstractviewcontrollertestcase: as an extension of abstractjsftestcase, this class provides an effective method for testing common scenarios that use viewcontroller implementation classes.
◆ Mock implementations of other JSF Web components are called mockapplication, mockexternalcontext, and mockfacescontext.

The shale test is also integrated with the Spring framework, allowing JSF components to be bound as management beans or spring beans.

The JSF extensions Project is a collection of non-UI components, which extends the JSF-based
1.2 of Web applications. It uses JUnit, htmlunit, and cactus for automatic testing. The test-time module of the Framework is JSF.
1.2 provide the mock object. The design-time module provides the JSF hot deployment function to stop and restart applications without the need to go through the build and re-deployment cycles. This is based on JSF
The features of the phaselistener interface will overload all configuration files and classes. These enable developers to follow a test-driven iterative JSF development method when writing JSF applications.

Tools

There are also some development tools to assist in the development of JSF applications and performance testing. Jshortred
The Group's jxinsight provides JSF tracking and Performance Detection features based on the phaselistener interface. Use this tracking listener in JSF applications, developers and Web
The administrator can collect information about a JSF request, such as the trace stack, Java call stack, and uicomponent hierarchy during runtime.

The JSF tool sub-project in the eclipse WTP project also provides tools to support the development and deployment of JSF-based Web applications, such as Visual JSF page editor and faces config editor.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.