Configure Eclipse with Cucumber

To configure Eclipse with Cucumber, we need to launch the Eclipse IDE, create a Workspace, create a Project and add External libraries to the project.

Step 1: Select WorkSpace on Eclipse start up

a) Double click on ‘eclipse.exe‘ to start eclipse. First time when you start eclipse, it will ask you to select your workspace where your work will be stored as shown in below image.
Start-Eclipse-1

b) Create a “working directory” for all of your projects. Think of it like “My Documents” in the Windows operating system. It’s a folder which contains a lot of your documents, but there’s nothing to prevent you from creating another folder called “My Other Documents” (for instance) to house other documents.
Typically you only need one workspace, and you can think of it as your “My Documents” for Java code. If you wanted to, you could have more than one, but chances are you won’t have a use for more. I like to choose my own workplace location and will place all my TESTING TOOLS QA TRAINING tutorial projects under it.
You can change it later on from ‘Switch Workspace‘ under ‘File‘ menu of eclipse. After selecting workspace folder, Eclipse will be open.

 
Start-Eclipse-3

c) You may see the window like this, this is the Welcome window for Eclipse. You may close this window.
Start-Eclipse-4

Step 2: Create a New Project

Projects: A collection of related code. Generally speaking, each project encompasses one independent program. Each programming assignment you do will typically require its own project.
Once you’ve established your workspace, you’ll want to create a project and begin writing code. In Eclipse, projects are the next-smallest functional unit after workspaces, but where you might have only one workspace, you will usually have several projects inside one workspace.
a) Create new Java Project from File > New > Java Project .
Setup-Project-1
Note: You may see a direct option for Java Project, if you are using the latest version of Eclipse like LUNA.

b) Select Java Project and click Next.
Setup-Project-2

c) Give your Project name ‘OnlineStore‘ as shown in below given figures. Click on Finish button.
Setup-Project-3

d) You may or may not see this message but if in case you get any, check ‘Remember my decision’ and  click on Yes.
Setup-Project-4
Now your new created project ‘OnlineStore‘ will display in eclipse project explorer.


Step 3: Add External Jars to Java build path

We are almost ready to write the first cucumber selenium test but before that we need to associate all the Selenium & Cucumber jars to the newly created project.
Add Selenium Jars
a) Let’s first add Selenium Jars. Right click on Project ‘OnlineStore’ > Select Properties > Java build path. Then navigate to Libraries tab and click Add External JARs.
Selenium-Jar-1

b) Add Selenium Java jar, you may add the source file too.
Selenium-Jar-2

c) Add all the jars from the libs folder as well.
Selenium-Jar-3

d) Click OK.
Selenium-Jar-4

Add Cucumber Jars
a) Right click on Project ‘OnlineStore’ > Select Properties > Java build path. Then navigate to Libraries tab and click Add External JARs.
SetUpCucumber_1

b) Add all the Cucumber’s Jars to the project and click Open.
SetUpCucumber_2

c) Click on Ok.
SetUpCucumber_3

d) This is how the project looks like in Eclipse as of now.
SetUpCucumber_4


That’s all about configuration of Cucumber & Selenium WebDriver with Eclipse. Now you are ready to write your test script in eclipse.