Home Java Overview Maven Tutorials

Monday 7 November 2022

Cucumber Tutorial with JUNIT

Hello Friends,
In this article , we will work with Selenium BDD (Behaviour driven development) using Cucumber.
So we will learn the cucumber with below topics :-

1). How to Configure/Install Cucumber in eclipse

2). How to create maven project & change it to cucumber project

3). Dependencies required to configure the cucumber

4). Create a feature file

5). Create step definition file

6). Create runner file

7). Run cucumber project

How to install the Cucumber plugin in Eclipse: please follow the below path in eclipse

Help -->> Eclipse Market Place --> Search "Cucumber" in search box --> Click on Install
as shown in below image

OR Help -->> Install New Software --> Click on Add button --> -->Save

Now Create a Maven Project

Now configure the POM.xml file == >Add Cucumber, Junit dependency , ==>> add plugins

<project xmlns="" xmlns:xsi=""




<!-- -->

<!-- -->
<!-- -->
<!-- -->

<!-- -->

<!-- -->



Create a Resource folder and feature file inside it

Create a package "StepDefinition" and created a class and write all steps definitions

Create a runner package and a runner class and add Cucumber Options

package Runner;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
@CucumberOptions(features = "D:\\Software\\Selenium\\01_Cucumber_Framework_2024\\WorkSpace\\way2testingCucumber\\Resource",
glue = {"Step_definitions"},
plugin = {"pretty", "html:target/cucumber-reports.html", "json:target/report.json"},
monochrome =true )
public class TestRunner {

Now run the cucumber test either via JUNIT or by Maven

SetUp Cucumber Maven JUnit from scratch

Create project with Cucumber Maven JUnit from scratch

No comments:

Post a Comment