0% found this document useful (0 votes)
36 views

Cucumber Notes

Uploaded by

LATHIKA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Cucumber Notes

Uploaded by

LATHIKA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Cucumber:

https://www.interviewbit.com/cucumber-interview-questions/

Cucumber is a behaviour-driven development (BDD) testing tool. It provides


a method for writing tests that anyone, regardless of technical knowledge,
can comprehend. We can write test scripts from both the developer's and
the customer's perspectives with Behavior Driven Development.

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:

1. Create a Feature File: Feature files are written in Gherkin syntax


and contain scenarios describing the behavior of your application.
Create a .feature file and write your scenarios using Given-When-Then
steps.
2. Run Cucumber Tests:
 To run Cucumber tests, you typically execute the test runner
class which will locate and execute your feature files.
In Java, you can use the JUnit or TestNG test runners. In Ruby,
you might use RSpec.
 Use the appropriate test runner command depending on your
programming language and test framework.
3. Step Definitions: Step definitions map the Given-When-Then steps in
your feature files to the actual code that should be executed. Each
step in the feature file corresponds to a step definition method.
4. Regular Expressions: Step definitions are matched to steps in
feature files using regular expressions. Regular expressions define
patterns that match step text.
5. Hooks: Hooks are blocks of code that run before or after each
scenario. They can be used for setup and teardown tasks such as
opening a browser before each scenario and closing it afterward.
6. Tags: Tags allow you to categorize your scenarios. You can run
scenarios with specific tags using the test runner's tag option.
7. Data Tables and Scenario Outline: Data tables and scenario
outlines allow you to parameterize your scenarios and run them with
different sets of data.

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.

Scenario Structure Keywords:


4. Scenario: Describes a specific test scenario.
5. Scenario Outline: Allows for the same scenario to be executed
multiple times with different inputs.
6. Examples: Provides different sets of data for a Scenario Outline.

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. Cucumber-JVM: The core implementation of Cucumber for Java


Virtual Machine-based languages like Java, Kotlin, and Groovy.
2. Cucumber-Ruby: The implementation of Cucumber for Ruby,
enabling behavior-driven development in Ruby projects.
3. Cucumber.js: Allows writing Cucumber tests in JavaScript for Node.js
applications.
4. Cucumber-Eclipse: Provides integration with Eclipse IDE for writing
and running Cucumber tests in Java.
5. Cucumber IntelliJ: Offers integration with IntelliJ IDEA for writing and
executing Cucumber tests in Java.
6. Cucumber Reporting: Provides enhanced reporting capabilities for
Cucumber test results, often used for generating HTML reports.
7. Cucumber Extent Report: Integrates Extent Reports with Cucumber
to generate rich and interactive HTML reports for test execution
results.
8. Cucumber TestNG: Integrates Cucumber with TestNG, allowing
Cucumber tests to be executed using TestNG's testing framework.
9. Cucumber Spring: Provides integration between Cucumber and the
Spring Framework for Java applications, enabling dependency injection
and other Spring features in Cucumber tests.
10. Cucumber Parallel: Enables parallel execution of Cucumber
tests, improving test execution speed by running scenarios
concurrently.

Tag Combinations used in Runner File:

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.

Sure, here are the names of some popular Behavior-Driven Development


(BDD) tools:

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

Scenario outline example

You might also like