In my CI server, I'm implementing some logging/audit functionality - after every Fit test runs, in the TearDown page I'm logging some stuff to DB - Test Name, TimeStamp, some variables; I would also like to log if the test failed or passed - don't seem to find any global variable readily available in FitNess that would help. Could anyone give me some ideas how to do that?
thanks! O.
TearDown doesn't know if a test passed or failed. That is only known by FitNesse after the test is complete. What you can do is run fetch the last execution as XML and then parse that. Here is a snipped from ANT that will do something like that.
<!--Then run the page history responder to get the latest run of fitnesse in xml format-->
<java classpath="${toString:compile.classpath};build\classes" fork="true" jar="javalib/fitnesse.jar" maxmemory="256m" output="${fitnesse.output.file}.temp">
<arg value="-c" />
<arg value="${fitnesseSuite}?pageHistory&resultDate=latest&format=xml" />
<arg value="-p" />
<arg value="${fitnesse_port}" />
</java>
The one catch is that after you fetch it, you have to strip the http headers from the temp file that is created. But once you do that, you can use the test result data for your database. You can also create junit style results. Check out this example on transforming to junit: http://whotestedthis.squarespace.com/journal/2012/1/26/transforming-fitnesse-results-to-junit.html (shameless self promotion).