Way2Automation - Tutorial 2 – Setting up cucumber in
eclipse
What you will Learn :
o Cucumber-BDD Framework design flow
o Create Maven project in eclipse
o Download cucumber eclipe plugin
o Delete the dummy packages
o Add properties to [Link]
o Add dependencies to [Link]
o Add plugins to [Link]
o Update maven project
Cucumber-BDD Framework Design Flow
First, let us understand the flow that we would be designing in our cucumber
framework. Look at the below figure. So basically, we would be given a document that
would comprise of many functional requirements or user stories. So, this document
would describe various requirements such as: how to perform a search for a particular
product? how to add a product to a cart? and so on…
We would then convert or map this requirement to the respective feature file. The
feature file would then be mapped to a step definition java file. Lastly, Testrunner java
file would execute respective features. For each user story, we would write the
corresponding feature file, step def file and Test Runner. So, memorize this design flow
(user story > feature file > Step def java > Test runner java) while designing framework
Create Maven project in eclipse
Open eclipse, File >New >Project >Select ‘Maven Project’, see below
Click Next
Click Next. In the below window, type ‘maven-archetype-quickstart’ in the ‘Filter’ text
field. Select the group id as shown below. It does not matter which version you see (here
1.1)
Click Next. Mention any desired ‘Group Id’ and ‘Artifact Id’. The name you mention in
‘Artifact Id’ would become the name of your maven project.
Click Finish
Wait for a minute or so. You should see a maven project getting created having the same
name as ‘Artifiact Id’. See below
You should see the same folder structure that you see above
Download cucumber eclipe plugin
This plugin is very useful that will help us to create multiple feature files, it will highlight
all the features/annotations in respective colors, the readability will be improved.
So just copy the url [Link]
In the eclipse, Help > Install New Software
Paste the url in the ‘Work with’ field as shown below
Hit ‘Enter’ key
You would see a checkbox named ‘Cucumber Eclipse Plugin’ as seen below
Select the checkbox ‘Cucumber Eclipse Plugin’ as seen below
As soon as you select the checkbox, ‘Next’ button gets enabled as seen above
Click ‘Next’
After a minute or so, the below window would come up
Click ‘Next’
Accept the license terms
Click Finish
The s/w starts getting installed (see right hand side bottom screen of eclipse)
After sometime you will get below popup
Click ‘Install anyway’
After the installation, below popup comes up
Click ‘Restart Now’
Delete the dummy packages
Next, delete the 2 dummy packages that were created when maven project was created
So after deleting, the project folders looks as below
Add properties to [Link]
Go to [Link]
This java skeleton is created by cucumber team. Scroll down the page, you would see
[Link]
Open [Link].
The below page would open, you would see some properties within the <properties>
tag. As can be seen below, the jdk version is 1.8, junit ver is 4.13.1, cucumber version is
6.9.1
Copy all these properties
Open the [Link] file in eclipse
Paste the properties in [Link]
Save the xml
Add dependencies to [Link]
Delete the dependency that is already present in [Link]
So we have
Next, go back to the skeleton, you would see 3 dependencies
Copy these and paste it in [Link]
Save the xml
Add plugins to [Link]
Add a blank line before </project> tag
Now go to the skeleton and copy the entire <build> tag section, see below
Paste it at line#44 in [Link]
Save the xml.
Expand ‘Maven Dependencies’ folder, see below. You would see that the various jars get
downloaded automatically
Update maven project
Next, right click your project > Maven > Update Project
The below popup comes
Click OK. The project gets updated with jdk 8, see below
Close [Link] file in eclipse.
So this is how we setup cucumber in eclipse.
Thank you for reading!