Monday, August 27, 2007

Selenium and CruiseControl

Surprisingly, running Selenium tests under CruiseControl seems to be one of the least-covered topics in the agile community.. After going through the few articles on the matter (a pretty good one here and a not so promising one on the CruiseControl wiki here) I decided to roll my own.

It seems that most solutions (well, I only found two so "most" might be a harsh word here :-) require some knowledge of NAnt (which I lack) and incorporate lot's of temporary files, logs, xsl-transformations, server scripts and other such cuss-words which all make me feel a bit sea-sick.

I prefer to keep things encapsulated and clean, so my idea was to make a simple task (say a command-line EXE that can be run through a simple CruiseControl <exec> task). This task would open up some kind of in-process HTTP-listener waiting for the Selenium results to come in, and then run the Selenium TestRunner in a browser, telling it to report back to our listener when it's done. Once the results come in - we just need to analyze them, return some Cruise-Control-friendly result code and close the browser. Simple, right?

Well in fact it *was* that simple, and worked like a charm! The highlight was using DotNet 2.0's HttpListener class with help from Rick Strahl's excellent wrapper posted here. The code is still all too spiky to show it's face in public, but I'll be sure to post it soon, so stay tuned!

No comments: