Cucumber Tutorial – How to setup Cucumber with Eclipse

In the previous tutorials, we have discussed about BDD (Behavior Driven Development) and GherkinCucumber is one such open source tool, which supports Behavior Driven Development (BDD). In simple words, Cucumber can defined as a testing framework, driven by plain English. It serves as documentation, automated tests, and a development aid – all in one.

In this tutorial, we will setup Cucumber with Eclipse. 

Prerequisites for Environment Setup for Cucumber

1. Download and Install Java

Java is a robust programming language. Java is a general-purpose programming language that is concurrent; class based and object oriented language. Java follows the concept of “write once and run anywhere (WORA) which means that compiled java code can be run on all different platforms that support java without the need of recompilation. Cucumber supports Java platform for the execution. Click here to know How to install Java

2. Download and Start Eclipse

Eclipse is an Integrated Development Environment (IDE). It contains a base workspace and an extensible plug-in system for customizing the environment. Click here to know How to install Eclipse

3. Maven –  How to install Maven on Windows 

Apache Maven is a software project management and comprehension tool. It uses the concept of a project object model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information. MAVEN helps us in creating the project structure, managing and downloading the dependencies. We need to define the required dependencies in pom.xml. Click here to know How to install Maven

4. Configure Cucumber with Maven
 Step 1 – Create a Maven Project. Click here to know How to create a Maven project
 Step 2 – Open pom.xml of the project
         1.Go to package explorer on the left hand side of Eclipse.
         2. Expand the project CucumberTest.
         3. Locate pom.xml file
         4. Add dependencies to POM.XML
    Step 3 − Add dependency for selenium:

This will indicate Maven that Selenium jar files are to download from the central repository to the local repository.                                                                             

3.1 Open pom.xml is in the edit mode, create dependencies tag (), inside the project tag.                                 

3.2 Inside the dependencies tag, create dependency tag ().

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.141.59</version>
</dependency>

  Step 4 –  Add dependency for Cucumber-Java

This will indicate Maven, which Cucumber files are to be downloaded from the central repository to the local repository.    Create one more dependency tag.

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>6.8.1</version>
</dependency>

Step 5 – Add dependency for Cucumber-JUnit

This will indicate Maven, which Cucumber JUnit files are to download from the central repository to the local repository. Create one more dependency tag. 

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>6.8.1</version>
    <scope>test</scope>
</dependency>

    Step 6 –  Add dependency for JUnit

This will indicate Maven, which JUnit files are to be downloaded from the central repository to the local repository. Create one more dependency tag.

<dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>4.12</version>
   <scope>test</scope>
</dependency>

Below is the screenshot which shows that Maven Project called CucumberDemo

This is the image of pom.xml created

After adding the above mention dependencies, pom.xml looks like the image below

After adding the dependencies and then build the project, below image shows the entire jar files added to the Maven Dependency.

2 thoughts on “Cucumber Tutorial – How to setup Cucumber with Eclipse

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s