0% found this document useful (0 votes)
31 views10 pages

Most Asked Cucumber BDD Interview Questions

Interview ques

Uploaded by

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

Most Asked Cucumber BDD Interview Questions

Interview ques

Uploaded by

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

Most Asked Cucumber BDD Interview Questions:

1) What is Cucumber?
Cucumber is a tool that supports Behaviour-Driven-Development (BDD) which
is used to write acceptance tests for the web application. Cucumber can be used
along with Selenium. Cucumber supports many other languages like Perl, PHP,
Python, Net etc.

2) What are the advantages of Cucumber?


-Cucumber supports different languages like Java.net and Ruby.
-It acts as a bridge between the business requirements and development code.
-It allows the test script to be written without knowledge of any code, it allows
the involvement of non-programmers as well.
-It serves the purpose of end-to-end test framework unlike other tools.
- Due to simple test script architecture, Cucumber provides code reusability.

3) What are the 2 files required to execute a Cucumber test scenario?


Step definition file and Test Runner file are the 2 files required to run a
cucumber test scenario.

4) What language is used by Cucumber?


Cucumber uses Gherkin language. It is a domain specific language which helps
you to describe business behaviour without the need to go into detail of
implementation. This text acts as documentation and skeleton of your
automated tests.

5) What is meant by a feature file?


The file, in which Cucumber tests are written, is known as feature files. The

.
6) What does a feature file consist of?
Feature file consists of different test scenarios written using Gherkin language
in Given/When/And/Then format.

7) What are the various keywords that are used in Cucumber for writing a
scenario?
Most common keywords used in Cucumber are: Feature Background
Scenario Given When Then And But

8) What programming language is used by Cucumber?


Cucumber supports a variety of different programming languages including
Java, JavaScript, PHP, Net, Python, Perl, etc. with various implementations.

1|Page LinkedIn: Shubham Sultane


9) What are the major advantages of Cucumber framework?

Cucumber Testing focuses on end-user experience


Style of writing tests allow for easier reuse of code in the tests

10) Provide an example of a feature file using the Cucumber framework.


Feature: Login to site
Scenario: User login with valid credentials
Given user is on login page
When user enters valid username
And user enters valid password
Then login success message is displayed

11) Provide an example of Scenario Outline using Cucumber framework?


Feature
Scenario Outline for Facebook
Given user navigates to Facebook
When I enter Username as "<username>" and Password as "<password>"
Then login should be successful
Example:
| username | password |
| username1 | password1 |
| username2 | password2 |

12) What is the purpose of Behaviour Driven Development (BDD)


methodology in the real world?
Behaviour Driven Development is a software development approach that allows
the tester/business analyst to create test cases in simple text language (English).
The simple language used in the scenarios helps even non-technical team
members to understand what is going on in the software project.

13) What is the limit for the maximum number of scenarios that can be
included in the feature file?
You can have as many scenarios as you like, but it is recommended to keep the
number at 3-5. Having too many steps in an example, will cause it to lose its
expressive power as specification and documentation.

14) What is the use of Background keyword in Cucumber?


A Background allows you to add some context to the scenarios in the feature. It
can contain one or more Given steps. It is run before each scenario, but after
any Before hooks. In your feature file, put the Background before the first
Scenario. You can only have one set of Background steps per feature. If you

2|Page LinkedIn: Shubham Sultane


them into different feature files.

15) What symbol is used for parameterization in Cucumber?


The steps can use <> delimited parameters that reference headers in the
examples table. Cucumber will replace these parameters with values from the
table before it tries to match the step against a step definition.

16) What is the purpose of Examples keyword in Cucumber?


A Scenario Outline must contain an Examples (or Scenarios) section. Its steps
are interpreted as a template which is never directly run. Instead, the Scenario
Outline is run once for each row in the Examples section beneath it.

17) What is the file extension for a feature file?


Extension for a feature file is .feature

18) What is the purpose of Cucumber Options tag?


@CucumberOptions annotation provides the same options as the cucumber jvm
command line. For Example: we can specify the path to feature files, path to
step definitions, if we want to run the execution in dry mode or not etc.

19) How can Cucumber be integrated with Selenium WebDriver?


We can integrate cucumber with selenium webdriver by adding all
dependencies/jars related to selenium and cucumber in the project.

20) When is Cucumber used in real time?


Cucumber should be used for verifying the most important parts of the
application using end-to-end tests. BDD should also be used to verify the
wanted behaviour using integration tests. Importantly, the businesses should be
able to understand these tests, so you can reduce uncertainty and build
confidence in what you are building.

21) Provide an example of Background keyword in Cucumber?


Feature: Add items to shopping cart
Background: User is logged in
Given user navigate to login page
When user submits username and password
Then user should be logged in successfully
Scenario: Search a product and add it to shopping cart
Given user searches for Hp laptop
When user adds the selected item to shopping cart
Then shopping cart should display the added item

3|Page LinkedIn: Shubham Sultane


22) Write a three-line code to show scenario outline?
Scenario Outline: Login to application
Given User enters <username> and <password>
Examples:
| username | password |
| [email protected] | Pass@123 |

23) What are the steps to generate a report in Cucumber?


For HTML reports, add html:target/cucumber-reports to the
@CucumberOptions plugin option.
@CucumberOptions(
features = "src/test/resources/features",
glue= {"stepDefs"},
plugin = { "pretty", "html:target/cucumber-reports" },
monochrome = true
)

24)What is the difference between Cucumber and JBehave?


Cucumber is a software tool that supports BDD. JBehave is a Java based
framework supporting Behavior-Driven Development (BDD).
Cucumber is based on features while JBehave is based on stories.

25) What is the language used for expressing scenario in feature file?
Cucumber uses the Gherkin language to define the scenario in feature file using
keywords like Given, Then, And, When, etc

26) What Are Before, After, BeforeStep and AfterStep Hooks?


Methods annotated with @Before will execute before every scenario. Methods
annotated with @BeforeStep execute before every step. Methods annotated with
@After execute after every scenario. Methods annotated with @AfterStep
execute after every step.

27) What Are Cucumber Tags? Why we use the Tags?


Tags are a great way to organise your features and scenarios. They can be used
for two purposes:
Running a subset of scenarios
Restricting hooks to a subset of scenarios

4|Page LinkedIn: Shubham Sultane


28) What Is Cucumber Dry Run?
Cucumber dry run is basically used to compile cucumber feature files and step
Definitions. If there are any compilation errors it will show when we use dry
run.

29) Explain what is Scenario Outline in Feature File?


Cucumber Scenario Outline is used to execute the same scenario multiple times
with different data sets.

30) What is Step Definition in Cucumber?


Step Definition is a java method that is linked to a step in the scenario in feature
file.

31) Explain what is BDD (Behaviour Driven Development)?


BDD is an Agile software development process that encourages collaboration
among developers, QA and non-technical or business participants in a software
project.

32) Define feature file? Mention the components of feature file?


Feature file is a file which consists of scenarios, steps and conditions for
different test cases. The following are the components contained by the feature
file: Feature Scenario Scenario Outline Steps in Given/When/Then
format.

33) What is the meaning of Steps in Cucumber tool?


Each step starts with Given, When, Then, And. Cucumber executes each step in
a scenario one at a time, in the given sequence. When Cucumber tries to execute
a step, it looks for a matching step definition to execute.

34) What is the difference between Given, When, Then steps in feature file?
Given steps are used to describe the initial context of the system i.e., the scene
of the scenario.
When steps are used to describe an event, or an action.
Then steps are used to describe an expected outcome, or result.

5|Page LinkedIn: Shubham Sultane


35) What are the programming languages supported by Cucumber?
Cucumber supports many programming languages like Perl, PHP, Python, .Net
and Java.

36) How many times scenario outline will be executed?


Scenario outline is run once for each row listed in the Examples section.

37) What is background and when it will be executed?


Background contains one or more Given steps, which are run before each
scenario.

38) Explain types of Hooks in Cucumber?


Following are the different types of hooks in cucumber: Before After
BeforeStep AfterStep

39) What is the pattern of writing Given, When, Then, And?


There is no strict pattern of writing these keywords and can be interchangeably
used based on the scenarios.

40) What is the use of glue property under Cucumber Options tag?
The glue is a part of Cucumber options that describes the location and path of
the step definition file.

41) What is the difference between Cucumber, JBehave and Specflow?


Cucumber is based on Ruby while JBehave is a Java based framework and
Specflow is a .Net based framework.

42) What are the two main purpose of using Gherkin?


Documents user scenarios
Writing an automated test in BDD

43) How to comment a line in Feature file?

6|Page LinkedIn: Shubham Sultane


44) Explain Cucumber Hooks?
Hooks are blocks of code that can run at various points in the Cucumber
execution cycle. They are typically used for setup and teardown of the
environment before and after each scenario.

45) Name any 3 popular BDD testing tools?


Cucumber, SpecFlow and JBehave

46) Cucumber Tags are case sensitive. True or False?


Tag names are case-sensitive.

47) Name any two testing frameworks that can be integrated with
Cucumber?
TestNG and Junit can be easily integrated with Cucumber.

48) Name any two build management tools that can be integrated with
Cucumber?
Maven and Ant are two build management tools which can be integrated with
cucumber.

49) Name any advanced framework design that can be used with
Cucumber?
Page Object Model can be used with Cucumber.

50) Selenium can be integrated with Cucumber. True or False?


True

51) Can you name any other BDD tools except Cucumber?
Behave, JBehave, and SpecFlow

52) Can we write cucumber tags ( @smoke , @Run etc ) above feature
keyword in feature file?
Yes. We can write these cucumber tags above the feature keyword.

53) What is the real time use of Cucumber?


Cucumber is used to write acceptance tests for a web application.

7|Page LinkedIn: Shubham Sultane


54
Eclipse IDE?
Cucumber Eclipse Plugin can be used for Cucumber integration in Eclipse.

55) What are the Gherkin keywords?


The main keywords in Gherkin are: Feature, Scenario, Given, When, Then,
And, But (Steps) Background Scenario outline Examples

56) If Before hook is available and background is available for a scenario,


in which order they will be executed?
Before hook will be executed first followed by the background steps for a
scenario.

57) Types of reports generated by cucumber JUNIT?


Following reports can be generated:
HTML
XML
JSON

58) How to run multiple feature files in Cucumber?


We can mention all the different feature file paths or the folder path in Junit
Runner file.

59) How to create feature file in Cucumber?


Create a new file with .feature extension under src/test/resources/features folder.

60) How to run Cucumber tests in parallel?


Cucumber can be executed in parallel using TestNG and Maven test execution
plugins by setting the DataProvider parallel option to true. Using the scenario
outline we can execute multiple scenarios with TestNG. One can use either
Maven SureFire plugin for executing the tests in parallel.

61) Is Cucumber open source?


Yes, Cucumber is an open source BDD framework.

8|Page LinkedIn: Shubham Sultane


62) What is the starting point of execution for feature files?
TestRunner is the starting point of execution.

63) Should any code be written within TestRunner class?


In a default TestRunner class, no code is required to execute it.

64) Can we use same step definition in different scenarios?


Yes. We can use same step definition in multiple scenarios.

65) What is the maximum number of steps that are to be written within a
scenario?
There is no fixed limit of steps within a scenario and it is completely dependent
on the application.

66) What software do you need to run a Cucumber Tests?


We need any IDE like Eclipse or IntelliJ and setup a Maven Java Project. Then
we need to add maven dependencies for cucumber-JVM, cucumber-core and
cucumber-Junit. After that we need to add Feature Files, Step Definition Files
and Test Runner file to run a cucumber test.

67) Cucumber Execution Starts from Where?


Cucumber execution starts from TestRunner file.

68) On what places you can write tags in feature file?


Tags can be placed above the following elements:
Feature
Scenario
Scenario Outline
Examples

69) What are the prerequisites for building a Selenium Cucumber


automation framework?
We need to include the relevant Maven dependencies for Selenium and
Cucumber.

9|Page LinkedIn: Shubham Sultane


70) What are Data Tables in Cucumber?
Data Tables are used in Examples for Scenario Outline. Scenario will be
executed for every row in the data table.

71) What are the cucumber assertions?

assertions available in any testing framework like TestNG or Junit.

72) What is Cucumber Report? Mention the benefits of Cucumber Report?


Cucumber Report contains details of the test execution like which scenarios
passed or failed, what are the steps within the scenarios, and other environment
details. This report can be shared with the project stakeholders for reporting
purpose.

73) Can we use TestNG with Cucumber?


Yes. We can use TestNG with cucumber. For that we need to extend
AbstractTestNGCucumberTests Class in Test Runner class.

74) What is the main difference between Scenario and Scenario outline?
-Scenario can be executed only once but Scenario outline can be used to
execute scenario multiple times with different sets of data.
-
contain examples.

75) Mention the main reasons behind using a simple programming


language such as Gherkin?
Gherkin is used in Cucumber to make it easy for non-technical people to
understand the scenarios as it is quite similar to English language. Business
Analysts can easily convert the business requirements into:
Features/Scenarios/Steps using Gherkin.

10 | P a g e LinkedIn: Shubham Sultane

You might also like