Cucumber Interview Questions
Cucumber Interview Questions
------------
Using Scenario Outline we can able to test the application with the multiple set of
data.
We must use the examples keyword to provide the multiple rows along with headers.
However Scenario helps to create either data table or step level cucumber
expression
Data table is a class using that we can implement the data sets in the step level
and it's not for
whole test.
We have different pre defined functions in datatable like asList, asLists, asMap
and asMaps and all,
No mandatory rule to have headers here. We can define the data sets without headers
as well.
Background is used in the feature file level to write the common pre steps(Mostly
Given) in the scenario level.
We can use only one background inside one feature file. Like browser Initilization
or Deleting the cookies, Writing logs can be written
inside the background. It even helps stack holder get some idea with respect to
precodntions.
If i talk about hooks is something which will be written in the class level to
acheive both pre and post condition.
4. What is Tags?
----------------
Tags can be applied in the feature file or Scenario level through @tagName.
and it should be written inside the runner class to filter the particular scenario
or feature.
In some cases we have the requirement common pre and post requisties of few
scneaio's there
we can get the tagged hooks as well.
If we want to ignore partcular scenario we can use tilt symbol (~) while writing
the tag name in the runner class.
5. DryRun vs Strict
---------------------
When we set dryRun and Strict as true, basically both help us to compare feature
file steps against Step definion class and will give the
missing snippets.
However DryRun will not allow us to exeucute the code where as Strict will exeucte
the code.
Feature File -> To define the bahaviour of the applications through gherkin
language using keywords like Given, When, And, Then, But and So..
Step Definion -> Its a class file to write the implementation of the steps written
inside the feature file.
Feature File is used in Cucumber to define the behaviours through Gherkin using
different keywords like Given When And Then But So..
We can have different sections like Feature, Scenario, Scenario Outline With
Examples and Background And all.
We can also exeucte the code from the feature file itself. It should have an
extension ".feature"
We should implement the feature file steps through annotation @Given, @When, @and,
@Then like that...
9. What is Cucumber?
--------------------
Cucumber is OS and Free of Cost tool and It supports almost all the Programming
language.
It has three important Components like Feature file, step definion class,
Junit/TestNG Runner Class.
It the Process used in software projects to perform end to end flow on Products.
Its not only for testers, everyone in the team or Company made their collaboration
through BDD.
Basically In the Projects, Once the PO, DEV team and QA Team after agreed upon the
business requirements they
will convert that into Englih formatted scenarios using Gherkin language.
So this scenarios used by the developer to develop an app,and testers use the same
scenarios to test the app and PO
use this one for Acceptance level of testing.
So here we are doing behavioural centric approach as the top one to write our
development code or Automation scripts.
We will directly define the test scripts and making it fail then will add
refactoring code to make them pass. This cycle goes On.
Its Test first approach or Code centric approach. Only technical persons can able
to understand code level things.
Whereas In BDD We will write the scenarios first and convert that into code and
making it fail then will add refactoring code to make them pass. This cycle goes
On.
12. How to Acheive data driven testing through Cucumber or Parameterization through
Cucumber?
--------------------------------------
1. In the Step level, Using Cucumber or Regular expressions we can able to send the
data from feature file to Step definion.
2. Using Datatable, Below the feature file steps we can given the data sets using
pipe symbol and then we can convert this table
by Datatable class.
Datatable class has different methods like asList, asLists, asMap and asMaps.
This one is for single test
3. Third way using Scenario Outline with Examples - we can able to test the
application with the multiple set of data.
This one is for whole test
* Natural Plugin
* Cucumber Plugin --> Active plugin and getting frequent releases.
* Cucumber-Java
* Cucumber-Junit/Testng