Cucumber Notes
Cucumber Notes
https://www.interviewbit.com/cucumber-interview-questions/
The Ruby programming language was originally used in the creation of the
Cucumber framework. Cucumber now supports a variety of programming
languages, including Java and JavaScript, through several
implementations. SpecFlow is the name of the open-source Cucumber port
for .Net.
Certainly! Here are some basic commands and concepts for working with
Cucumber:
For theory:
1. Gherkin syntax: Ensure you have a strong grasp of writing clear and
concise feature files using Gherkin syntax, including scenarios,
scenario outlines, and tags.
2. Step definitions: Understand how step definitions are written in your
programming language of choice (e.g., Java, Ruby) and how they
interact with Cucumber to execute scenarios.
3. Hooks: Learn about hooks in Cucumber and how they can be used to
set up preconditions or clean up after scenarios.
4. Data tables and scenario outlines: Explore how to use data tables
and scenario outlines effectively to parameterize your scenarios and
make them more reusable.
5. Tags and filtering: Understand how to use tags to organize and filter
your scenarios, allowing for selective test execution.
6. Best practices: Familiarize yourself with best practices for writing
maintainable and efficient Cucumber tests, including guidelines on
feature file structure, step definition organization, and scenario design.
Keywords:
Sure, here's a one-liner description for each keyword along with Hooks:
Structural Keywords:
1. Feature: Describes a feature or functionality of the software.
2. Background: Defines steps that are common to all scenarios within a
feature file.
3. Rule: Defines a high-level business rule in the feature file.
Step Keywords:
7. Given: Describes the initial state or preconditions for the scenario.
8. When: Describes the action or event that occurs.
9. Then: Describes the expected outcome or result of the scenario.
10. And: Chains together Given, When, or Then steps.
11. But: Specifies an exception or alternative condition to the
previous step.
Additional Keywords:
12. Hooks: Executes setup and teardown actions before and after
scenarios or test events, such as starting and stopping services or
setting up test data. Hooks are not directly defined within feature files
but are part of the test automation infrastructure.
Hooks:
Cucumber Plugin Names:
1. Single Tag:
@smoke: Executes scenarios tagged with @smoke.
2. Multiple Tags (Logical AND):
@regression and @ui : Executes scenarios tagged with both
@regression and @ui.
@regression and not @wip : Executes scenarios tagged with
@regression but not @wip.
3. Multiple Tags (Logical OR):
@api or @integration : Executes scenarios tagged with either
@api or @integration.
@slow or @performance : Executes scenarios tagged with either
@slow or @performance .
4. Combination of AND and OR:
(@critical or @high) and not @deprecated : Executes scenarios
tagged with either @critical or @high but not @deprecated.
5. Using Parentheses for Grouping:
(@sanity or @smoke) and (@ui or @api) : Executes scenarios
tagged with either @sanity or @smoke and also tagged with
either @ui or @api.
6. Combining Logical AND, OR, and NOT:
(@regression or @smoke) and not (@ui or @integration) : Executes
scenarios tagged with either @regression or @smoke but not
tagged with either @ui or @integration.
1. Cucumber
2. JBehave
3. RSpec
4. Cucumber-JS
5. Jasmine
6. Behave
7. Lettuce
8. SpecFlow
9. NUnit
10. Behat
11. PHPSpec
12. Gauge
13. FitNesse
Sample code