Search code examples
javarestfitnesse

Need to implement custom Fitnesse responders


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!


Solution

  • 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. :)