Jon Archer wrote last week about how Cucumber makes knowledge of regular expressions important. He’s right: Regular expressions are the key to Cucumber’s flexibility. Well-crafted regular expressions let you reuse step definitions, avoiding duplication and keeping your tests maintainable. But even experienced developers find them mysterious and overwhelming.

Fortunately, you don’t need regular expressions like this one to wield the power of Cucumber:

1
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

In fact, if you use regular expressions like this in your step definitions, you’ve gone too far. (This regular expression, in case you’re wondering, matches the official spec for valid email addresses.)

As with most things, the 80/20 rule applies. There are a handful of useful patterns that are sufficient to make you a Cucumber power user. [click to continue…]

{ 5 comments }

I’m excited to announce that Paul Rayner’s company, Virtual Genius, has joined The Agile Cooperative. Paul is the founder and president of the Denver chapter of the International Association of Software Architects (IASA). I’ve known him for the last couple years through IASA and Agile Denver.

On top of a great Australian accent, Paul brings to the Cooperative expertise in agile architecture and engineering practices. Earlier this year, Paul and I co-taught and consulted on Acceptance Test Driven Development with Cucumber. I’m very pleased to formalize what is already a great partnership.

Learn more about Paul on the Virtual Genius blog. Or subscribe to the combined Agile Cooperative feed to get new blog posts from all the Cooperative members.

{ 1 comment }

Debugging Cuke4Nuke Step Definitions

January 12, 2010

At a client today, we were doing some tricky automation with WatiN (against Telerik controls) in Cuke4Nuke. We wanted to dig into what WatiN was finding in the browser. The obvious move was to fire up the debugger. But with Cuke4Nuke, this is trickier than you might think. The Cuke4Nuke gem includes a release build—no [...]

Read the full article →

How to Remove Duplication in Cucumber Tests Using Scenario Outlines

January 4, 2010

Gojko Adzic has a new blog post demonstrating the new table parameter support in Cuke4Nuke. Table parameters are an important part of Cucumber. They’re great for setting up data and asserting that lists are what you expect. But I use them much less often than the other kind of table in Cucumber, scenario outlines.

Read the full article →

The Latest on Cuke4Nuke

December 30, 2009

This morning, I released version 0.3.0 of Cuke4Nuke. With this release, Cuke4Nuke supports almost everything you can do with Cucumber in Ruby or Java, making C# a first class language for Cucumber. (The only missing features are small things like tags on Before and After hooks and a richer Table object.) Check out the Cuke4Nuke [...]

Read the full article →

Growing DONE—How to Make the Definition of Done Work for Your Team

December 21, 2009

Effective agile teams get things done. They build software day after day that’s not just “code complete” but really shippable. And when their product owner says, “ship it,” they can get their shippable software into production at the drop of a hat. The Definition of Done can be a powerful tool to make these things [...]

Read the full article →

Screencast: Testing Web Applications in .NET with Cuke4Nuke and WatiN

December 3, 2009

Yesterday, I released Cuke4Nuke 0.2.2, which added WatiN compatibility and an example of how to use the two tools together. Here’s a short screencast in which I walk through the example: Resources from the video: The Cuke4Nuke Wiki with installation instructions WatiN Source code from the example The new Ruby installer

Read the full article →

Crazy Thanksgiving Offer: Let's Make Your Work Great

November 25, 2009

Work shouldn’t suck. Whatever your position, you can do something to make your work better. I’m so thankful for the work I get to do, I want to share the goodness. So here’s my crazy Thanksgiving offer: If you subscribe to this blog or follow me on Twitter and you don’t love your job, tell [...]

Read the full article →

WatiN Patterns #3: Don’t Over-specify

October 30, 2009

After a long hiatus, I’m resuming the WatiN Patterns series. Pattern #1 covered why and how your tests should clean up after themselves. Pattern #2 covered how you should name your tests and why they should only assert one thing. Pattern #3 is about keeping your tests maintainable by specifying just enough in your element [...]

Read the full article →

Patterns for Splitting User Stories

October 28, 2009

Good user stories follow Bill Wake’s INVEST model. They’re Independent, Negotiable, Valuable, Estimable, Small, and Testable. The small requirement drives us to split large stories. But the stories after splitting still have to follow the model. Many new agile teams attempt to split stories by architectural layer: one story for the UI, another for the [...]

Read the full article →