Monday, 15 December 2008

Testing web applications? Cucumber is the cool new kid on the block

I've had quite complimentary things to say about Canoo WebTest, but one thing it doesn't provide out of the box is a representation of the tests that your average customer is able to read and understand intuitively - that is to say, a tabular format like Fit or a narrative of the "Given... when... then... " form.

Cucumber to the rescue! I heard several people mention this at the recent XP Day in London. I hope to investigate it in more depth soon.

I would be interested to know whether it can be used to test anything other than Ruby code and whether it can drive a web browser to interact with Rich Internet Applications (RIAs). Stuart Ervine's and Nat Pryce's GWT development demo at XP Day was truly impressive. Nat has combined WebDriver with WindowLicker to create a clean interface between a test script and synchronous or asynchronous RIAs. But telling a jUnit test to move the mouse cursor into a particular widget and click the button was nothing if not verbose!

4 comments:

SimoneC said...

Cucumber is the the new name of rSpec, specifically it is used to specify user acceptance test. To drive a web app you need to use Cucumber with other tools like Watir or Selenium.
I wrote a couple of example on how to use Cucumber with Watir and in my team we are using it together with FunFx to write acceptance test for Flex. If you are interested I can show you something when I'm back in London :)...

Nat Pryce said...

Hi Immo. The gestures in the test we demo'd was verbose because we wrote out the entire gesture at the lowest level: move the mouse to the center of the element, click button 1, etc.

In practice, those gestures are issued by higher-level drivers that represent how one interacts with specific GWT widgets (e.g. press button, enter text into a field, and so on), and *those* drivers are wrapped up into drivers that represent how the user performs tasks (logs in, enters an order, etc.).

That structure makes tests much more concise, as the example in my "TDD of Asynchronous Systems" talk showed. But it's application specific and more than I could write in 5 minutes!

Immo Hüneke said...

Hi Simone,

I am not sure you're correct in stating that Cucumber is the new name for rSpec. According to the project home page, Cucumber was dependent on rSpec for a while, but the latest version has removed that dependency. But that's not important - I would be really keen to see your use of the tool. A good subject for a lightning talk at a forthcoming staff meeting, I think!

Best regards, Immo

SimoneC said...

Hi Immo, thanks to point that out. You are right it would be more correct to say that it is the new rSpec runner according to the rSpec website (http://rspec.info/).
I will show you a very good example that I'm working on...