

BDD Cucumber Interview Questions and Answers
1.What is Behaviour Driven Development (BDD) ?
Ans: Behaviour Driven Development is a software development process based on Test Driven Development(TDD) that focuses on addressing the behaviour of software applications. It involve writing test cases in a plain english like language for every functionality of the application. This result in increased collaboration among developers,testers and all other stakeholders involved in the software development process.
2.What is Cucumber? Mention its advantages.
Ans: Cucumber is a tool used to execute test cases that are written in a plain english like language using Gherkin syntax. Cucumber is written in Ruby Programming language. The various advantages of Cucumber are
- Extensive focus on user experience
- Cucumber ensures the participation of Business stakeholders even with zero coding knowledge.
- Promotes higher reusability of code.
- It is an open source tool without any license requirement
- It needs less maintenance and it is scalable.
- Test cases in Cucumber are written in a plain english like language which makes it easy for non technical persons to understand.
3. Mention the files that are used in executing Cucumber test scenarios.
Ans. Two files are used to execute Cucumber test scenarios.
- Feature File
- Step Definition File
4. What are the features of BDD?
Ans. The Features of BDD are
- There is a shift from thinking in “tests” to thinking in “behaviour”
- Effective Collaboration between Business Stakeholders,Business Analysts,Development team and QA Team.
- Test Scenarios are written in a plain easily understandable language.
- It is driven mostly by Business Value.
- It extends TDD by utilising plain language that even non technical persons can understand.
- BDD frameworks like Cucumber,JBehave act as a bridge between business and technical language.
5. What is Gherkin in Cucumber?
Ans: Gherkin is a language with the help of which we can write structured test cases in a plain easily understandable language which can be used for project documentation. It ensures test cases are written in a structured way that enables the testers to perform automated testing using Cucumber/Spec flow.
6. What are the keywords used in Gherkin?
Ans: The various keywords used in Gherkin are as follows:
- Feature
- Rule
- Background
- Scenario
- Scenario Outline
- Given
- When
- Then
- And
- But
- ‘*’
7. What is a Feature File in Cucumber?
Ans: Feature File is the starting point of Cucumber tests.This is a file where all test scenarios are written in a simple english like language using gherkin syntax.It is an important part of Cucumber which acts like an automation test script as well as live document.A Feature file can contain either a single test scenario or multiple test scenarios but it mostly contains multiple test scenarios.
8. What are the components of the Feature File?
Ans. The various components of Feature File are:
a)Feature: It gives a description of the current test script that is to be executed.
b)Scenario: It describes the expected results of a particular test case.
c)Scenario Outline: It helps to execute scenarios with different set of inputs.
d)Given:It mention the conditions of the test that will be executed.
e)When:It mentions the test actions to be performed.
f)Then:It Represents the expected result of the test.
9. What is Step Definition?
Ans. Step Definition is a piece of code which is attached with a pattern. In other words Step Definition is a java method in a class where an annotation is present above it. An annotation is followed by a pattern which links the Step Definition to the matching steps and code execution will be done by Cucumber when it sees a Gherkin Step. Cucumber is able to find out the Step Definition File using Glue Code present in Cucumber Options.
10. What is Cucumber Options?
Ans. In non technical language Cucumber Options are similar to property files or settings used for test cases. Cucumber Options enables testers to perform all activities that were supposed to be done using Cucumber Command Line.
11. Mention all the Options available in Cucumber.
Ans. The Options available in Cucumber are
a) dryRun- Its default value is false.It checks whether all the test steps have correct definition .
b) features-It is used to set the path of feature files. Its default value is “{}”.
c)glue-It sets the path of the step Definition files. Its default value is “{}”.
d)tags- It gives instructions regarding what tags will be executed in the feature file.Its default value is “{}”.
e)monochrome- It displays the output console in a clear and readable way. Its return type is false.
f)format- Its default value is false. It decides what all report formaters to be used.
g)strict- Its default value is false. It fails the test case execution if it finds out some missing or undefined steps.
12. What is the use of Tags in Cucumber?
Ans. Tags are used to organize the Features and Scenarios.All the scenarios present in a Feature file are by default executed by Cucumber.Tag is used to run a particular test scenario from the Feature File.
Syntax:
@TagName
Scenario:Test the scenario
13. What are Cucumber Hooks?
Ans. Hooks are code blocks that get executed before and after every scenario.They can be defined anywhere in the project or step definition layers using @Before and @After methods. It allows to manage the code workflow effectively and reduces code redundancy. It is basically an unseen step that allows to execute the test cases or scenarios.
14. Mention the programming languages supported by Cucumber.
Ans. Cucumber supports various programming languages like Perl,PHP,Python,.Net and Java.
15. Name the types of Hooks used in Cucumber.
Ans. The Hooks used in Cucumber are Before,After,BeforeStep and AfterStep.
16. Mention the plugin which integrates Cucumber with Eclipse IDE.
Ans. Cucumber Eclipse plugin is used to integrate Cucumber with eclipse.
17. What are data tables in Cucumber?
Ans. Data Tables are used in examples for Scenario Outline.Each scenario is executed for each row of the data table.
18. What is Cucumber Report?
Ans. Cucumber Report is a document that contains the details of the total test excited, the tests passed, number of test failures, steps for every test scenarios and other environment details.
19. What is the necessary precondition for setting of Selenium Cucumber Automation Framework?
Ans. Before setting up Cucumber it is necessary to add all the dependencies of Selenium Cucumber.
20. Mention the difference between Scenario and Scenario Outline.
Ans. Scenario outline helps you to pass examples in test script Whereas scenario helps you to hardcode test data and execute.
Conclusion
In conclusion, mastering Cucumber as a software testing tool can greatly enhance your testing skills and efficiency. By following this tutorial and gaining hands-on experience, you are equipping yourself with valuable knowledge that can propel your career in Software Testing Cucumber to new heights. We hope this tutorial has been beneficial in deepening your understanding of Cucumber and its role in the testing process. Keep practising and exploring new possibilities with Cucumber to continue honing your skills as a software tester.
Also read :
Consult Us