Today I learned… that I can “tag” select Cucumber scenarios and run just the tagged ones, speeding up my testing and making it faster to debug a failing test.
I’m working with Ruby Cucumber tests for my current project and as the tests grew in number and complexity, I found myself wanting a way to run just a specific test.
If your tests are set up anything like mine, you can just add a tag with an @ symbol to your tests like so:
When you run your Cucumber tests from the command line, just add –tag @tagname as an argument:
cucumber --tag @tagname test/specs/features/testfile.feature
This is just a simple implementation that might be useful if you are trying to debug a single test. Taken to its logical conclusion, you could have entire suites organized under different tags for different purposes, environments, etc.
Most of what I know about Cucumber tagging came from krazyrobot.com’s excellent guide on Cucumber tagging.