views:

264

answers:

3

Hi,

I believe that I am in need of implementing custom Fitnesse responders for a client but have not found much success in my research/attempts to make this work. The idea is that the client will have suites of tests written in Fitnesse but that the results will be published to their database via a web service on their local intranet. We would like to either call the test via a URL in a RESTful manner and/or invoke the custom responder via another button on the Fitnesse page. Ideally this would run the test, gather and parse the results, then publish via the web service. I was hoping that I might get some ideas/hints as to how to make this happen because I'm about at my wits end. @_@ Any help would be greatly appreciated! Thanks!

+1  A: 

I've been investigating the same thing, and this is what I believe to be the case...

You can invoke any FitNesse test in a RESTful manor. E.g. To execute a test and get results in XML: http://myHost:myPort/MyWikiPage?responder=test&format=xml.

See the FitNesse page FitNesse.UserGuide.RestfulServices for more information about interacting RESTfully with FitNesse.

The problem with this RESTful approach, for what you want to do, is that it requires you to wrap the execution of FitNesse; which means that if you want users to be able to run tests through the normal Go-To-The-Wiki-And-Press-The-Test-Button, no results will be sent to your system in that case. As you eluded, the solution to this problem seems to be via custom responders.

I believe the answer is to extend the FitNesse Test responder (and the Suite responder). If you can find out in the existing responder source code where the results are available, then you should be able to override that method to additionally process the results however you need to and send them off to your external system.

Responders have to be registered with FitNesse. This is done via a file called plugin.properties (in the same location as fitnesse.jar). See the FitNesse page FitNesse.UserGuide.PluginUsage for more information. I'm assuming that FitNesse allows default responders to be overridden, so your definition in plugin.properties would look something like this:

Responders=test:your.package.TestResponder, suite:your.package.SuiteResponder

One thing to think about is whether or not you always want results sent to your external system. For example, when tests are being developed, it doesn't always make sense to clutter the result repository. Maybe you only really want to send results when the tests are run as part of a regression. These factors might dictate what you choose to do, like add another button to "Test & Send Results", or only deploy your custom responders to the systems where you regress your tests, or create a property that you set on a Test to "Send Results When Run".

I'd be curious to know which way you go; and if you get the responder to work, I wouldn't mind knowing your solution. :)

A: 

I also have had trouble with this, more from just getting Fitnesse to run RESTfully from the command line in Powershell, I can run the URL's directly and have the results be captured with PowerShell but when using REST I can't even get Powershell to connect. If you have a mechanism to get this to run I'd be curious to see how you can do it, but if all you want is a way to run scripts and get results Powershell can do it and you could use it to push results to a database if you need.

MichaelF
A: 

Actually, I don't think you need a custom responder at all. When you use the restful services interface to run a suite, you get back a block of XML similar to the following:

<?xml version="1.0"?>
    <suiteResults>
      <FitNesseVersion>v20100103</FitNesseVersion>
      <rootPath>MgmtSuite</rootPath>
        <pageHistoryReference>
        <name>FrontPage.MgmtSuite.GroupTest</name>
        <date>01/07/2010 09:21:46</date>
        <pageHistoryLink>FrontPage.MgmtSuite.GroupTest?pageHistory&amp;resultDate=20100107092146</pageHistoryLink>
        <counts>
          <right>1</right>
          <wrong>1</wrong>
          <ignores>110</ignores>
          <exceptions>3</exceptions>
        </counts>
      </pageHistoryReference>
        <pageHistoryReference>
        <name>FrontPage.MgmtSuite.SchedulesTest</name>
        <date>01/07/2010 09:22:07</date>
        <pageHistoryLink>FrontPage.MgmtSuite.SchedulesTest?pageHistory&amp;resultDate=20100107092207</pageHistoryLink>
        <counts>
          <right>1</right>
          <wrong>1</wrong>
          <ignores>344</ignores>
          <exceptions>7</exceptions>
        </counts>
      </pageHistoryReference>
        <finalCounts>
        <right>0</right>
        <wrong>2</wrong>
        <ignores>0</ignores>
        <exceptions>0</exceptions>
      </finalCounts>

    </suiteResults>

The suite results contains each test that was run, and a summary of each test. If you gra this XML, you should be able to iterate through each test, and get the page history link which you can use to request the history file for that specific test. You can specify either XML or HTML as the output, take that result and save it away.

(note, the XML you see above is actually suiteHistory format instead of the standard XML that you receive back when you call the suite directly. The general format is the same).

There is a story on Pivotal Tracker where functionality is needed to be able to request the LATEST run of a test or suite. Not sure when that will be ready, but you might not actually need it.

Dan Woodward