Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tl;dr
This pull request builds on
guard-cucumber
to allow developers to dynamically focus on specific scenarios in their Cucumber feature files. This has made working with specific Cucumber scenarios a lot easier for me.Focusing on cucumber scenarios is already easy
Say i’m working on a “User Management” feature. It lives in
features/user_management.feature
. It includes a variety of user scenarios, but the ones I want to test in particular are about how users invite each other to the app.Right now I can do this by specifying a tag to focus on in the
guard-cucumber
initializer in my Guardfile. Like so:guard 'cucumber', :cli => ‘—tags @focus’
And then I put
@focus
above every invitation scenario that I want to focus on:That’s great, now cucumber will only test the scenarios where one user invites another to the system. That was easy.
But dynamically adjusting the focus is hard
Now i’m done testing invitations and I want to be sure that the rest of my “User Management” scenarios are working. I delete my focus tags from the
user_management.feature
file. Then I save the file, expectingguard-cucumber
to run all the scenarios.Nothing happens, no tests run. If I want to run all my tests again, I have to:
user_management.feature
fileGuardfile
—tag
option in theguard-cucumber
initializer.feature
to run tests againWhat if I want to focus on a different subset of scenarios? I have to repeat all the steps above.
The pull request makes dynamic focusing easier
This pull request aims to remove steps 2-5 from this process. It does this by allowing the user to tell
guard-cucumber
which tag to focus on, like so:guard 'cucumber', :focus_on => ‘focus’
When
guard-cucumber
sees that thefocus_on
key has a value, it focuses on scenarios tagged with that value. (@focus
, in this example). If@focus
was found, it updates the feature file’s path using the standard cucumber notation. Then it hands off that updated path to cucumber. For example, if@focus
was found on line 6:cucumber user_management.feature:6
would eventually run. If the user removes the
@focus
tag from the file (in order to run all scenarios) thenguard-cucumber
will run all scenarios in that file.Who Cares
People who use rspec can dynamically focus on tests using the
:focus
symbol. You add the symbol to a specific test, and it will run that test only. You remove the symbol and all tests run. These guys requested something like this in the cucumber mailing list.Thanks, this has made testing and development much smoother for me lately, especially when i’m working with cucumber tests.