PMC:QA:Hudson with fitnesse
Contents
- 1 Test fitnesse with hudson
- 1.1 Fitnesse installing
- 1.2 Hudson installing and configuration
- 1.3 integrating FitNesse with hudson
- 1.4 References
- 1.5 Links
Test fitnesse with hudson
Fitnesse installing
Dowmload fitnesse from http://fitnesse.org/FrontPage.FitNesseDevelopment.DownLoad
download the .zip file.and decompress it,run "run.sh" or "java -jar fitnesse.jar".
Then open browser http://localhost/
Hudson installing and configuration
install and run
download hudson from https://hudson.dev.java.net/
for tomcat, you can put it to webapps folder under tomcat_home,then start it, it will run and monitor.
or run "java -jar hudson.war"
goto http://serveradderess/hudson,if you see the hudson page, it is successful
add compile tools
goto Manage Hudson->Configure System
click add ant in "Ant installation"
input parameter name such as ant-1.7.1
input parameter ANT_HOME such as /usr/share/ant
integrating FitNesse with hudson
Start Fitnesse
Start Fitnesse as a demon process in our build
Invoke Fitnesse‘s TestRunner class with following
- a Specify XML as the output format and the path to the XML file (You can give both XML and HTML as the output format)
- b Host and Port on which Fitness is running
- c The path to the Fitnesse Test Suite URL (Ex: FrontPage.TestSuite)
Edit a build.xml(and i put this build file at fitnesse home directory) file as following:
That is a example:
Adding this to your build file, will enable you to run Fitnesse tests from your ant build file.
create a new job in hudson and configure it
run hudson and open it by browser:http://serveradderess/hudson
click "New Job" to create a new job.
put in "Job name" like "fitnesseTestResult",and select its type "Build a free-style software project",then click ok button.
Ok!Now you created a new job name as "fitnesseTestResult".
Configure hudson
click the new job goto its main page,select "configure"
Configure hudson to include the top build file:
build -> Add build step -> Invoke Ant
save it.
Build The new job
Build the new job,it will build it as the build file.
click "Build Now",you will see:
select the building one.
then select "Console Output"
you will see the build result.
Write the test result to xml file
Top,we get fitnesse test results by console,and we can write them to xml file.
Create fitnesse output dir and file,add them to build file
write test results to xml file
add codes to build.xml file as follow:
to replace:
Write XSLT (stylesheet) to display the results correctly
fitnesse2junit.xsl
<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:element name="testsuite"> <xsl:attribute name="tests"> <xsl:value-of select="sum(testResults/finalCounts/*)" /> </xsl:attribute> <xsl:attribute name="failures"> <xsl:value-of select="testResults/finalCounts/wrong" /> </xsl:attribute> <xsl:attribute name="disabled"> <xsl:value-of select="testResults/finalCounts/ignores" /> </xsl:attribute> <xsl:attribute name="errors"> <xsl:value-of select="testResults/finalCounts/exceptions" /> </xsl:attribute> <xsl:attribute name="name">AcceptanceTests</xsl:attribute> <xsl:for-each select="testResults/result"> <xsl:element name="testcase"> <xsl:attribute name="classname"> <xsl:value-of select="/testResults/rootPath" /> </xsl:attribute> <xsl:attribute name="name"> <xsl:value-of select="relativePageName" /> </xsl:attribute> <xsl:choose> <xsl:when test="counts/exceptions > 0"> <xsl:element name="error"> <xsl:attribute name="message"> <xsl:value-of select="counts/exceptions" /> <xsl:text> exceptions thrown</xsl:text> <xsl:if test="counts/wrong > 0"> <xsl:text> and </xsl:text> <xsl:value-of select="counts/wrong" /> <xsl:text> assertions failed</xsl:text> </xsl:if> </xsl:attribute> </xsl:element> </xsl:when> <xsl:when test="counts/wrong > 0"> <xsl:element name="failure"> <xsl:attribute name="message"> <xsl:value-of select="counts/wrong" /> <xsl:text> assertions failed</xsl:text> </xsl:attribute> </xsl:element> </xsl:when> </xsl:choose> </xsl:element> </xsl:for-each> </xsl:element>
</xsl:template> </xsl:stylesheet>
create target process output file by xsl file and add this target
to replace:
build by hudson
- fitnesse-test-results.xml
- Test-fitnesse.xml
Publish JUnit test result report
In order to publish JUnit test result report,we should put the "out put dir" to hudson project workspace.at out linux:/root/.hudson/jobs/fitnesseTestResult(that is project name)/workspace
* create the output dir and file.
* then modify build file
* configure hudson
select your project -> configure
as follow:
save.
* build again * view the result
click your new building,you will find test result at its page after building completed.
select "test result" and view.here we can see the test result.
and you can view all test by select "all tests"
* the project index page
here we can see "Test Result Trend"
References
* http://www.jroller.com/njain/entry/integrating_fitnesse_with_cruisecontrol * http://andypalmer.com/ * http://code.supergloo.com/2007/07/28/automating-fit-tests-in-fitnesse-server-from-cruise-control-hudson-bamboo-via-ant/
Links
- Go back to PMC:QA