Learning Cukes


I’ve written [several] [posts] [in] [the] [past] about my team’s adoption of SpecFlow and BDD, and I’m still loving it several months later. The large project that we started with has nearly 10,000 lines of code and 93% code coverage. We’ve gone through several large refactors, and each time we walk away with a high level of confidence that no functionality was lost or affected negatively. It’s been a really great experience.

One of the challenges of adoption was just learning the Cucumber step definition syntax, or rather, how to write cukes. For getting started, I recommend taking a look at this page for a good list of descriptions, scenarios, and examples. If you’re using SpecFlow, you may also want to check out their step definition documentation on GitHub.

Once you’ve got the basic syntax down, the hard part begins. My team hasn’t had much formal discussion about Cucumber best practices, and we’re still learning what works and what doesn’t. If you look around online, you can find a few good articles with helpful suggestions, though.

Here’s a great post that I recommend reading. This article offers advice on just about every aspect of creating and managing your cukes, from feature files to tags to running and refactoring.

I also found this post from EggsOnBread to be very helpful. All of the recommended practices are good. This was one of the first articles I read when I was getting started, and it’s served me well. I’ll be honest, though–many of the points didn’t stick during my initial read. It became much more valuable after spending several months working with Cucumber and then re-reading.


Author: Adam Prescott

I'm enthusiastic and passionate about creating intuitive, great-looking software. I strive to find the simplest solutions to complex problems, and I embrace agile principles and test-driven development.

4 thoughts on “Learning Cukes”

  1. Have you been able to integrate the built in Code Coverage functionality of VS testing (i.e. configured in the testsettings file) with your specflow tests? I’m having a lot of trouble getting it working – any pointers you could give would be great! I don’t get any coverage information from the tests that are executed through the webdriver. I am getting coverage information from other normal tests though, so I know it works…

    1. Code coverage works just fine for me, but this is in VS2012 so I didn’t have to monkey around with the testsettings file. Unfortunately, I don’t have any suggestions off the top of my head. What version of VS are you working with?

  2. I’m using VS2010 – code coverage is actually working, it’s just not calculating coverage for the tests that are run through specflow – and I expect this is because MSTest isn’t actually running the tests, as in a unit test where mstest hooks directly into my assemblies – instead mstest is instructing the webdriver what to do in a browser… Thanks.

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: