0% found this document useful (0 votes)
2 views7 pages

Cucumber Testing Tips and Best Practices

Cucumber and Tips(briefly) Scenarios Written in YAML Scenario: Eat Cake given there is cake when I go to the cake page and I press "Eat Cake" then I should see "There is no more cake" Avoid Excessive Givens Each given loads data and is held in a transaction for the scenario. Seed data where possible rather than establishing it in givens Tagging features tag features and scenarios with : @tag @tag2 Feature: cake Run specific tags with: cucumber

Uploaded by

bmcleodlundy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Cucumber Testing Tips and Best Practices

Cucumber and Tips(briefly) Scenarios Written in YAML Scenario: Eat Cake given there is cake when I go to the cake page and I press "Eat Cake" then I should see "There is no more cake" Avoid Excessive Givens Each given loads data and is held in a transaction for the scenario. Seed data where possible rather than establishing it in givens Tagging features tag features and scenarios with : @tag @tag2 Feature: cake Run specific tags with: cucumber

Uploaded by

bmcleodlundy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODP, PDF, TXT or read online on Scribd

Cucumber and Tips(briefly)

Scenarios

● Written in YAML
● Scenario: Eat Cake

given there is cake


when I go to the cake page
and I press “Eat Cake”
then I should see “There is no more cake”

Get clients or stakeholders in on the writing


process.
Steps
When /^I go to (.+)$/ do |page_name|
visit path_to(page_name)
end

Generic is better.
Dealing with slow test suites
Just target one feature:
Cucumber features/[Link]

Specify by line number:


Cucumber features/[Link]:29
Avoid Excessive Givens
● Each given loads data and is held in a
transaction for the scenario.

● Seed data where possible rather than


establishing it in givens
Tagging features
● Tag features and scenarios with :
@tag @tag2
Feature: cake
● Run specific tags with:
cucumber --tags @tag

● The @wip tag applies automatically to all


features currently unfinished.
Validate your HTML
● Throw in a step to validate your HTML
● markup_validity gem
Then %r/the page is valid XHTML/ do
$[Link] be_xhtml_strict if ENV["VALIDATION"]
end

● Equal opportunity for front end people to get


laughed at for breaking the build.

You might also like