Getting started with Cucumber tool and Environment setup

Cucumber is a tool which helps BDD (Behaviour driven development). It is a tool which supports multiple programming language implementations like Java, JS, PHP, Ruby, Python, C# etc.

In this series of cucumber tutorials, we are going to work with Java programming language.

Environment setup of Cucumber tool with Java:

Pre-requisite:

– JDK and JRE installed on the system
– Java path defined in the environment variables
– Eclipse IDE installed on the system

To set up the environment you can go through – Environment setup Java and Creating a project in Maven.

Add Cucumber jar files to the project:

– cucumber-core
– cucumber-java
– cucumber-java-deps
– cucumber-jvm
– Gherkin

Go to Maven Repository website and search for all above jar files and download them.
– https://mvnrepository.com/

Once you download all the jar files include them in your project by – Right-click Project Name >> Build Path >> configure Build path >> Libraries >> Add External Jar >> Navigate to the path where you have kept the jar files >> select all the jar files >> Click Apply >> Click OK.

Add Maven dependencies:

If you are using Maven as build management tool add below dependencies to your pom.xml file.

	<dependencies>
		<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
		<dependency>
			<groupId>info.cukes</groupId>
			<artifactId>cucumber-core</artifactId>
			<version>1.2.5</version>
		</dependency>

		<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
		<dependency>
			<groupId>info.cukes</groupId>
			<artifactId>cucumber-java</artifactId>
			<version>1.2.5</version>
		</dependency>

		<!-- https://mvnrepository.com/artifact/info.cukes/gherkin -->
		<dependency>
			<groupId>info.cukes</groupId>
			<artifactId>gherkin</artifactId>
			<version>2.12.2</version>
			<scope>provided</scope>
		</dependency>

		<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-jvm-deps -->
		<dependency>
			<groupId>info.cukes</groupId>
			<artifactId>cucumber-jvm-deps</artifactId>
			<version>1.0.5</version>
			<scope>provided</scope>
		</dependency>
	</dependencies>

Installing Cucumber plugin for Eclipse:

This tool is not a mandatory tool but it makes your cucumber code looks good and properly formatted.

Cucumber eclipse plugin helps eclipse to highlight the Gherkin language syntax which makes it easy for the user to work and understand easily.

To install this plugin follow these steps:

Navigate to help of eclipse >> Install New Software >> Click Add >> Enter name – Cucumber and Location – http://cucumber.github.com/cucumber-eclipse/update-site >> Click OK.

Eclipse will search for the plugin >> Once it shows the plugin select the plugin >> click Next multiple times.

Accept the license >> Finish.

If it shows some warning click OK.

The cucumber eclipse Plugin will take some time to install. Restart the eclipse.

Now we are ready to start working with cucumber. In the next tutorial, we will create and run our first test case.

Saurabh Dhingra

About the Author

Saurabh Dhingra

Follow Saurabh Dhingra: