2. How to install cucumber in Eclipse

To start using cucumber in eclipse we need to install few things:

  1. First of all eclipse and Java Development Kit (JDK) need to be installed on the computer.
  2. Ones eclipse finished with the installation we are able to install “Cucumber Eclipse Plugin” with eclipse built-in plugin installation tool. Step by step instructions can be found here.
  3. Download cucumber libraries. Multiple solution can be found here. We recommend to use Maven to download and manage all dependencies.

Our pom.xml contains the following dependencies:

<dependency>
	<groupId>info.cukes</groupId>
	<artifactId>cucumber-picocontainer</artifactId>
	<version>1.2.5</version>
</dependency>
<dependency>
	<groupId>info.cukes</groupId>
	<artifactId>cucumber-java</artifactId>
	<version>1.2.5</version>
	<scope>test</scope>
</dependency>
<dependency>
	<groupId>info.cukes</groupId>
	<artifactId>cucumber-jvm</artifactId>
	<version>1.2.5</version>
	<type>pom</type>
</dependency>
<dependency>
	<groupId>info.cukes</groupId>
	<artifactId>cucumber-junit</artifactId>
	<version>1.2.5</version>
	<scope>test</scope>
</dependency>
<dependency>
	<groupId>net.sourceforge.cobertura</groupId>
	<artifactId>cobertura</artifactId>
	<version>2.1.1</version>
</dependency>
<dependency>
	<groupId>info.cukes</groupId>
	<artifactId>cucumber-jvm-deps</artifactId>
	<version>1.0.5</version>
</dependency>
<dependency>
	<groupId>net.masterthought</groupId>
	<artifactId>cucumber-reporting</artifactId>
	<version>1.0.0</version>
</dependency>
<dependency>
	<groupId>info.cukes</groupId>
	<artifactId>gherkin</artifactId>
	<version>2.12.2</version>
</dependency>
<dependency>
	<groupId>org.mockito</groupId>
	<artifactId>mockito-all</artifactId>
	<version>2.0.2-beta</version>
</dependency>
<dependency>
	<groupId>junit</groupId>
	<artifactId>junit</artifactId>
	<version>3.8.1</version>
	<scope>test</scope>
</dependency>
<dependency>
	<groupId>org.seleniumhq.selenium</groupId>
	<artifactId>selenium-java</artifactId>
	<version>3.0.1</version>
</dependency>

This pom.xml dependency list includes:

  • usual cucumber jars
  • picocontainer – It is a collection of the common objects for test steps in different classes. Sort explanation can be found here.
  • Selenium
  • JUnit – Cucumber is built on top of JUnit, which means that cucumber tests cannot run without JUnit.

Java Runtime Environment (JRE) is not enough to run Cucumber tests, so please ensure that you have Java Development Kit (JDK) installed. If JDK is not set properly in eclipse it will give compilation error “Missing Artifact com.sun:tools:jar”. To solve this we can set an additional dependency into pom.xml:

 <dependency>
   <groupId>com.sun</groupId>
   <artifactId>tools</artifactId>
   <version>1.6</version>
   <scope>system</scope>
   <systemPath>C:\Program Files\Java\jdk1.8.0_101\lib\tools.jar</systemPath>
 </dependency>

Similar Posts from the author: