Testing / Cucumber Interview Questions
How do you implement data-driven testing using Scenario Outline and Examples in Cucumber?
Data-driven testing in Cucumber centers on pairing a Scenario Outline, containing angle-bracket placeholders, with an Examples table supplying the concrete values for each run.
Scenario Outline: discount calculation by customer tier Given a customer with tier "<tier>" And a cart total of <cartTotal> When the discount is calculated Then the discounted total should be <expectedTotal> Examples: standard tiers | tier | cartTotal | expectedTotal | | bronze | 100 | 100 | | silver | 100 | 90 | | gold | 100 | 80 | @edgeCase Examples: edge cases | tier | cartTotal | expectedTotal | | gold | 0 | 0 |
Cucumber substitutes each row's values into the outline's placeholders and executes the resulting concrete scenario independently, reporting each one separately. Splitting the data into multiple named and separately tagged Examples blocks, as shown with the edge-case table above, keeps the standard cases and edge cases organized and lets a tag expression selectively run just the edge-case set if needed, without touching the standard set.
More Related questions...