Cucumber Interview Questions and Answers
Ques 11. What is the purpose of the 'Outline' keyword in Cucumber?
The 'Outline' keyword is used to create a template for a scenario with placeholders for input values, and it is often used with the 'Examples' keyword.
Example:
Ques 12. How can you run specific scenarios in Cucumber?
Specific scenarios can be run by using the tag associated with those scenarios in the Cucumber test execution command.
Example:
cucumber --tags @smoke
Ques 13. What is the purpose of the 'DataTable' in Cucumber?
DataTable is used to represent tabular data in Gherkin syntax, providing an easy way to pass data to steps in a scenario.
Example:
Scenario: Data-driven login
Given the user is on the login page
When the user enters the following credentials
| Username | Password |
| user1 | pass123 |
Then the user should be logged in
Ques 14. Explain the difference between 'Background' and 'Scenario Outline' in Cucumber.
Background is used to define a set of common steps for all scenarios in a feature, while Scenario Outline is used to run the same scenario with different sets of data.
Example:
Feature: Online Shopping
Background:
Given a user is logged in
Scenario Outline: Add item to cart
When the user adds- to the cart
Then the cart should display the
Examples:
| item |
| Laptop |
| Headphones|
Ques 15. What is the purpose of the 'DocString' in Cucumber?
DocString is used to pass a large string as an argument to a step, providing a way to include multiline data in a step definition.
Example:
Scenario: Add product description
Given the user is on the product page
When the user adds the following description
"""
This is a detailed description of the product.
It includes features and specifications.
"""
Then the description should be saved
Most helpful rated by users: