We're using Cucumber and Selenium with Ruby. After reading the <a href="https://github.com/cucumber/cucumber/wiki/Hooks" rel="nofollow">documentation on hooks</a> I've tried my hand at setting a few tags to set (for example) some environment variables.
Here's a contrived example that demonstrates the problem.
When I establish a
Before hook like so:
Before('@tag1', '@tag2') do puts "in the before hook!" end
It'll take effect with a scenario defined like so:
@tag1 @tag2 Scenario Outline: This is a test scenario Given I run my first step for "<user>" Then I complete my test @firstrun Scenarios: |user| |fred| @secondrun Scenarios: |user| |barney|
..however if I move
@tag2 to the individual scenarios and not the scenario outline, the hook is never called, for instance:
@secondrun @tag1 @tag2 Scenarios: |user| |barney|
Is it possible to 'hook in' individual scenarios, or just the outlines?Answer1:
Typically with scenario outlines the table of values you're testing is tied to that, not separate scenarios.
ScenarioOutline Given I am on gmails website When I login as <user> with <password> Then I am able to view my primary inbox Example: | user | password | | Fred | xd13#%& |