### Create new RichFaces Documentation Jira issue

Summary
255 characters left
Description
Environment
This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.org Community Documentation

- Prev
- Next

## Chapter 7. Generating unit tests

Unit testing is a method of testing that verifies the individual units of source code are working properly. A unit is the smallest testable part of an application, method for example.

The goal of unit testing is to isolate each part of the program and show that the individual parts are correct. Unit tests find problems early in the development cycle and allow you to perform code refactoring at a later date, and make sure the module still works correctly. By testing the parts of a program first and then testing the sum of its parts, integration testing becomes much easier.

Unit testing provides a sort of living documentation of the system. You could learn unit functionality by looking at the unit test and get a basic understanding of the unit API.

## Note:

Unit testing cannot be expected to catch every error in the program. It only tests the functionality of the units themselves. Therefore it is more effective if the other software testing activities are used in conjunction with unit tests.

Unit tests generated by CDK check all the properties of the component, resources availability, and perform render test view.

In order to add unit tests to the project you should take the following steps:

- proceed to the inputDate/src/main/config/component directory, open the inputDate.xml file

- add the <test> element nested to <component> in order to generate unit test for the UIInputDate class

      ...

      <test>

          <classname>org.richfaces.component.html.HtmlInputDateComponentTest</classname>

          <superclassname>org.ajax4jsf.tests.AbstractAjax4JsfTestCase</superclassname>

      </test>

      ...

- add the <test /> element nested to <tag> in order to generate unit test for the InputDateTag class

      ...

      <tag>

          <name>inputDate</name>

          <classname>org.mycompany.taglib.InputDateTag</classname>

          <superclass>org.ajax4jsf.webapp.taglib.HtmlComponentTagBase</superclass>

          <test/>

      </tag>

      ...

- proceed to the inputDate directory, and add new execution with the generate-tests goal to pom.xml

      ...

      <execution>

          <id>generate-test-sources</id>

          <phase>generate-test-sources</phase>

          <goals>

              <goal>generate-tests</goal>

          </goals>

      </execution>

      ...

- launch the following command in the inputDate directory

      mvn clean install

If all the tests have been run successfully, the "BUILD SUCCESSFUL" message will appeared.

You could also find detailed tests information in the surefire reports placed in the inputDate/target/surefire-reports directory.

- PrevChapter 6. Developer sample creation
- Top of page
- Front page
- NextChapter 8. Button component development