PMC:QA:Hudson with fitnesse

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken 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:

Hufi13.png


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

Hufi.png

save it.

Build The new job

Build the new job,it will build it as the build file.

click "Build Now",you will see:

Hufi1.png

select the building one.

then select "Console Output"

Hufi2.png

you will see the build result.

Hufi3.png

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

Hufi4.png

write test results to xml file

add codes to build.xml file as follow:

Hufi5.png

to replace:

Hufi14.png


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

Hufi17.png

to replace:

Hufi16.png


build by hudson

Hufi6.png

  • fitnesse-test-results.xml
  • Test-fitnesse.xml

Hufi7.png

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.

Hufi18.png

   * then modify build file

Hufi15.png

   * configure hudson

select your project -> configure

as follow:

Hufi8.png

save.

   * build again
   * view the result

click your new building,you will find test result at its page after building completed.

Hufi9.png

select "test result" and view.here we can see the test result.

Hufi10.png

and you can view all test by select "all tests"

Hufi11.png

   * the project index page

here we can see "Test Result Trend"

Hufi12.png

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/

Hufi12.png

Links