facebook
Are you an Employer?
List of Topics

Cucumber JUnit Runner


Cucumber JUnit Runner

What is Cucumber JUnit Runner?

It is important to recognize what Junit is, earlier than we start our discussion for Cucumber JUnit Runner. JUnit is an open source unit trying out framework for the Java programming language. JUnit has been crucial in the development of test-driven development, and is one of a family of unit testing frameworks, that is together referred to as xUnit that originated with SUnit.

Benefits of the usage of JUnit

  • Unit has a Graphical user Interface (GUI), making it possible to write and test supply code speedy and easily.
  • JUnit allows the developer to incrementally build take a look at suites to degree development and detect unintentional side results.
  • Test can be run constantly.
  • JUnit suggests test progress in a bar that is commonly green but turns red when a check fails.

By way of now, we've seen the advantages of the usage of JUnit, however the reason we are discussing it proper now could be Cucumber framework. On one hand, Cucumber is presenting a way for non-technical person to outline check cases for a product, and then again, our expectation is for smooth and timely execution of such test cases.

JUnit acts as a bridge among these . So, the glide of execution will seem like the subsequent −

  • Stakeholders write down the feature record.
  • Step definition report will be created thus.
  • Specify the JUnit runner elegance to run the collection of test cases.
  • Once we run the JUnit runner magnificence −
  • It will parse the Gherkin characteristic document.
  • It’s going to execute the capabilities written in the step definition document in step with feature report statements.
  • JUnit will integrate the test case result.
  • It’s going to build the check file inside the distinctive format (which can be html/JSON).

The essential factor right here is how to configure JUnit to do all these items? Following are the steps −

Step 1 − install Java.

  • Download jdk and jre from the link http://www.oracle.com/technetwork/java/javase/downloads/index.html
  • Accepted license agreement.
  • Install JDK and JRE.

Cucumber - JUnit Runner

Step 2 − Install Eclipse.

Why we need − Eclipse is an integrated development surroundings (IDE). It consists of a base workspace and an extensible plug-in system for customizing the environment.

The way to install −

  • Make sure JAVA is installed on your system.
  • Download Eclipse from http://www.eclipse.org/downloads
  • Unzip and Eclipse is installed.

Step 3 − Install Maven.

Why we need − Maven is a build automation tool used usually for Java projects. It offers a not unusual platform to carry out sports like generating source code, compiling code, packaging code to a jar, and so on. also later if any of the software program versions receives changed, Maven offers an easy way to modify the check challenge therefore.

How to Install –

  • Download Maven − https://maven.apache.org/download.cgi
  • Unzip the file and remember the location.
  • Create environment variable MAVEN_HOME as shown in the following screenshot.

Cucumber - JUnit Runner

  • Edit Path variable and include Maven as shown in the following screenshot.

Cucumber - JUnit Runner

Down load MAVEN plugin from Eclipse.

  • Open Eclipse.
  • Go to help → Eclipse marketplace → search maven → Maven Integration for Eclipse → install.

Step 4 − the way to configure Cucumber with Maven

  • Create a Maven assignment in Eclipse.
  • Go to file → New → Others → Maven → Maven project → next.
  • Offer organization identification (organization identification will perceive your mission uniquely across all projects).
  • Offer artifact identification (artifact id is the call of the jar without version. you may choose any call that's in lowercase).
  • Click on finish.
  • Open pom.xml
  • Go to package explorer at the left hand side of Eclipse.
  • Extend the assignment CucumberTest.
  • Locate pom.xml report.
  • Right-click and select the option, Open with “textual content Editor”.
  • Upload dependency for Selenium − this will indicate Maven, which Selenium jar documents are to be downloaded from the central repository to the local repository.
  • Open pom.xml is in edit mode, create dependencies tag(<dependencies></dependencies>), in the assignment tag.
  • Inside the dependencies tag, create dependency tag. (<dependencies></dependencies>),
  • Provide the following information in the dependency tag.

• Add dependency for Cucumber-Java − this may suggest Maven, which Cucumber files to be downloaded from the primary repository to the local repository.

  • create one extra dependency tag.
  • Provide the following information within the dependency tag.


• Add dependency for Cucumber-JUnit: this could suggest Maven, which Cucumber JUnit files are to be downloaded from the important repository to the local repository.

  • Create one extra dependency tag.
  • Provide the following statistics inside the dependency tag.


• Add dependency for JUnit − this will imply Maven, which JUnit documents are to be downloaded from the important repository to the local repository.

  • Create one extra dependency tag.
  • Offer the following records within the dependency tag.

  • Verify binaries

  • Once pom.xml is edited successfully, save it.

  • Go to Project → Clean − It will take a few minutes.


• After that you will be able to see a Maven repository like the following screenshot.

Cucumber - JUnit Runner

Step 5 − Create feature file (to be covered later).
Step 6 − Create step definition file (to be covered later).
Step 7 − Create Junit runner to run the test (to be covered later).