Forum breadcrumbs - You are here:ForumBoozang Forums: Cucumber / BDDHow to write data-driven Cucumber …
You need to log in to create posts and topics.
How to write data-driven Cucumber tests
ljunggren@ljunggren
294 Posts
#1 · May 15, 2020, 4:39 pm
Quote from ljunggren on May 15, 2020, 4:39 pmSometimes it's great to use the Examples key-word to drive data loops. It's bad practice to over-use data in the Feature file - only put that that is relevant to the business, not developer test-data.
Also, use n-wise/pairwise testing practices to reduce the number of data rows.
@Discount
Feature: Discount Management
This feature covers the basic discount scenarios.@Smoke @Debug
Scenario Outline: Order product with different discounts
"""
Orders a product with different discounts
"""
Given I am a brewer
and I add a product
and I set inventory to price <price>, discount dollars <discount_dollars>,
percentage <discount_percentage>, and special price <special_price>
When I order <order_quantity> products
Then the order details should have subtotal <subtotal>
Examples:
|price|order_quantity|discount_dollars|discount_percentage|special_price|subtotal|
|20.00|1 |5.99 |bz-skip |bz-skip |14.01 |
|10.00|1 |bz-skip |25 |bz-skip |7.50 |
|32.99|1 |bz-skip |bz-skip |8.99 |8.99 |
|9.81 |10 |bz-skip |15 |bz-skip |83.39 |
|7.15 |10 |bz-skip |15 |bz-skip |60.78 |
Sometimes it's great to use the Examples key-word to drive data loops. It's bad practice to over-use data in the Feature file - only put that that is relevant to the business, not developer test-data.
Also, use n-wise/pairwise testing practices to reduce the number of data rows.
@Discount
Feature: Discount Management
This feature covers the basic discount scenarios.@Smoke @Debug
Scenario Outline: Order product with different discounts
"""
Orders a product with different discounts
"""
Given I am a brewer
and I add a product
and I set inventory to price <price>, discount dollars <discount_dollars>,
percentage <discount_percentage>, and special price <special_price>
When I order <order_quantity> products
Then the order details should have subtotal <subtotal>
Examples:
|price|order_quantity|discount_dollars|discount_percentage|special_price|subtotal|
|20.00|1 |5.99 |bz-skip |bz-skip |14.01 |
|10.00|1 |bz-skip |25 |bz-skip |7.50 |
|32.99|1 |bz-skip |bz-skip |8.99 |8.99 |
|9.81 |10 |bz-skip |15 |bz-skip |83.39 |
|7.15 |10 |bz-skip |15 |bz-skip |60.78 |
Click for thumbs down.0Click for thumbs up.0