Cucumber Interview Questions

Cucumber Interview Questions

Cucumber is a software tool used by computer programmers for testing other software. It runs automated acceptance tests written in a behavior-driven development style. Central to the Cucumber BDD approach is its plain language parser called Gherkin.

21.What is step definition in cucumber?

A Step Definition is a Java method with an expression that links it to one or more Gherkin steps. When Cucumber executes a Gherkin step in a scenario, it will look for a matching step definition to execute.

22.What is Data Tables?

Data Tables are handy for passing a list of values to a step definition:
Feature file:
Given the following animals:
| cow |
| horse |
| sheep|

Step definition:
@Given(“the following animals:”)
public void the_following_animals(List animals) {

//Lines of code }

23.What is cucumber.yml file in cucumber ?

Cucumber.yml file will create cucumber profiles.

24.What is cucumber dry run ?

Cucumber dry run is used to compile cucumber feature files and step Definitions. If there is any compilations errors it will show when we use dry run.

25.What are Cucumber options? What are its properties?

Below are cucumber options

  1. Feature – This involves the path to the feature file
    2. Glue – Defines path of step definition file.
    3. Dry run – This checks missing definition.
    4. Tags – scenarios in the feature file are grouped with the help of this property.
    5. Strict – This helps on making an execution stop if some of the steps are missing.
    6. Monochrome – Output is displayed in more readable format in console.

26.Can we use TestNG with cucumber?

Yes, we can use TestNG or Junit with cucumber.

27.How does the Cucumber execution start?

The file gets loaded at first in Support and it is generally the env.rb file. Then the hooks.rb file gets loaded. Finally, the steps of the scenarios get executed from the feature file.

28.What are the advancement frameworks available with the Cucumber tools?

The following are the advancement frameworks available with the Cucumber tools –
1. Page Object Model
2. Object Repository
3. Extent Reporting
4. Dependency Injection
5. Log4j

29.What are the meanings of support, hooks.rb and env.rb?

Support related to Cucumber tools are put forward in the Support folder.

For the execution of the scenarios of Cucumber tests requires the libraries to be loaded and for this env.rb is used.

Before, before step, after, after step – these types of hooks are added with the help of hooks.rb.

30.How will you execute specific scenario using line number?

We can select the target scenario from a feature file by providing its line number.
cucumber features/test.feature:10 –format html > testfeature.html

31.What is Test Runner in cucumber?

Test runner is a class which is use to run feature files and we define @CucumberOptions in it.
One can define the location of features, glue files (step definitions), and formatter plugins inside this Cucumber options.

32.In which language cucumber feature file is written?

In Gherkin cucumber feature file is written.

33.What is the execution priority in cucumber?

Execution priority: TestNG’s @BeforeClass → Cucumber’s @Before → Cucumber Background → Cucumber Scenario → Cucumber’s @After → TestNG’s @AfterClassQuestions 34 : What code will you write in cucumbre hooks?

Before hook, one can implement code to open web browser which is a prerequisite for all scenarios.
After hook, one can take a snapshot of failure and close the browser.

 35.Can we use same step definition in different scenarios?

Yes, can we use same step definition in different scenarios but with condition that corresponding step in one scenario is used as it is in different scenario.

36.Can we have two step definition for one scenario step?

No , we cannot have two step definition for one scenario step.

37.Explain What Is Scenario Outline In Feature File?

Scenario Outline: Same scenario can be executed for multiple sets of data.

38.What Is Step Definition In Cucumber?

A step definition is the actual code implementation of the feature mentioned in the feature file.

39.What are the two files which you need to run a Cucumber test scenario?

If you want to execute a Cucumber test, then make sure it has the following two files.
1- A feature file.
2- A step definition file.

40.List out some of the main differences between Jbehave and Cucumber?

The Cucumber and Jbehave share the same perspective, but there are few key differences.
1- Jbehave is Java-based and Cucumber is Ruby-based.
2- Jbehave is story-driven whereas the Cucumber is feature-driven.

Leave a Reply

Your email address will not be published. Required fields are marked *