Why using FIT?
Test Driven development is an Integral part of Agile processes. As part of Test Driven Development FIT is a good choice to be used as an automated test framework for acceptance testing.
Why using CruiseControl?
Usually agile processes suggest that continuous build and testing must be part of the development process. CruiseControl,in a very flexible and configurable manner,accommodates automating and scheduling the build and testing of an under development code.
As the above suggests, CC and FIT are very likely to be used in an agile project and I thought sharing some information on how CC can run FIT tests and display FIT reports can be beneficial. If you know of any better solution please let me know.
Please Note that CC provides a plug-in for displaying FITNESS test results and not FIT test results. If you are working with FITNESS and need to configure CC to show the test results for Fitness tests then see Fitness Reporting posting on gmane.comp.java.cruise-control.user newsgroup for an example.
I assume the reader of this posting already knows how to configure a project on Cruise Control. In case you do not know how to do it you can find more info on the following sites:
-Getting Started with CC document: CruiseControl Getting Started
-11 easy steps to get CC going: CruiseControl - Getting Started in 11 easy steps
Let’s assume the target project is already using FIT. Below I show you how to create an ant target for running your fit tests and also configure CC to use it:
1. Create two properties that are available to your build.xml for FIT input and output folders:
For example:
fit.storytests.dir=src/test/com/sentinel/test/fit/storytests
fit.results.dir=${build.dir}/fitReports
2. Create an ant target in your build.xml for running FIT Tests in your project:
* Add fitlibrary classpath:
<path id="fitlibrary.classpath">
<fileset dir="${libs}" includes="fitlibraryRunner.jar"/>
</path>
* Add fit test classpath:
<path id="fit.test.classpath">
<pathelement location="${build.test.classes.dir}"/>
…
<pathelement location="${build.classes.dir}"/>
<path refid="fitlibrary.classpath"/>
</path>
* Add build targets:
<target name="fit.test.prepare" depends="compile.test,fit.test.clean"
description="Prepare to do fit test"/>
<target name="fit.test.clean">
<delete dir="${fit.results.dir}"/>
</target>
<target name="test.fit" depends="fit.test.prepare" description="runs fit tests">
<echo>Please see the Fit Test Report page for more details on following
results:</echo>
<java classname="fitlibrary.runner.FolderRunner" fork="yes" failonerror="yes">
<classpath refid="fit.test.classpath"/>
<arg value="${fit.storytests.dir}"/>
<arg value="${fit.results.dir}"/>
</java>
</target>
3. To test you changes and run the fit tests run: ant test.fit
4. Create an snapshot of your project under CC and create a Project element in CC config.xml.
5. Create a file called fitLink.jsp and place it under [Cruise Control Home]\webapps\cruisecontrol directory. fileLinks.jsp provides a link to your FitReport folder under artifacts directory. Leave the ouput folder point to fitReports folder under build directory inorder to have the FIT test reorts published under CC artifacts. This is the content of fileLink.jsp:
-------------------------------
<%@ taglib uri="/WEB-INF/cruisecontrol-jsp11.tld" prefix="cruisecontrol"%>
</p><p>
<table width="98%" border="0" cellspacing="0" cellpadding="2" align="center">
<tr>
<td colspan="4" class="unittests-sectionheader">
Fit Tests:
</td>
</tr>
<tr>
<td class="unittests-data" colspan="2">
<cruisecontrol:artifactsLink>
<table width="98%" border="0" cellspacing="0" cellpadding="2" align="center">
<tr><td class="unittests-data"><a href="<%= artifacts_url %>/fitReports/reportIndex.html" target="_blank">View Fit Results</a></td></tr>
</table>
</cruisecontrol:artifactsLink>
</td>
</tr>
<tr>
<td>
<table width="98%" border="0" cellspacing="0" cellpadding="2" align="center"></table>
</td>
</tr>
<tr></tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
-------------------------------
6. Modify the buildResults.jsp file in the above directory to include fileLink.jsp. To do so include the line below at the bottom of buildresults.jsp:
<jsp:include page="./fitLink.jsp"/>
7. Inlcude the test.fit target in the build.xml file used by this project on CC.
<project name="myProject" default="build" basedir=".">
<target name="build">
<!-- Call the target that does everything -->
<ant antfile="build.xml" target="clean"/>
<ant antfile="build.xml" target="deploy-all"/>
<ant antfile="build.xml" target="test"/>
<ant antfile="build.xml" target="test.fit"/>
</target>
</project>
8. Restart your CC and open CC home page in your browser.
9. Press the build button for your new poject.
10. After the build is completed you should see a summary report of FIT test results on your project build result page in Errors\Warning section. At the bottom of the page you should also see a FIT Test section that provides a link to FIT Reports page.