top of page

Selenium Cucumber Java BDD Framework Basic – Setup

These are the basic steps to create Java BDD Framework.

1. Create a new maven project

Open Eclipse IDE and click File>Project>Select Maven project

Give project name and finish. For example :I have given name "Cucumber Java " and created my project

We can view our project name in project explorer on lefthand side.

2.Add requires maven dependencies like Cucumber Java | Cucumber Junit| Junit| Selenium Java

Type maven repository in google and search the repositories mentioned above. And add all the repositories in pom.xml. We can see our pom.xml looks like this.

Once we update our project we can view updated maven dependencies in "Maven Dependencies "folder

3. Create a folder Features under src/test/resources.

I have created a folder named "Features" inside that I have created a feature file login. feature

4. Download cucumber plugin from Eclipse Marketplace

Once we download Cucumber Eclipse plugin from Eclipse Marketplace and restart the eclipse we view our feature file like this

5. Create a feature file and add contents

For example : I have created login feature file and added contents like this

Feature: feature to test login functionality

Scenario: Verify login is sucessful with valid credentials

Given Admin is on login page

When Admin enter valid credentials and clicks login button

Then Admin should land on login page

6. Try to run the feature file and add Step Defenition/Glue Code under src/test/java package

Once I run the feature file I got snippet. And I created StepDefenition package inside my src/test/java directory. And created Loginsteps class inside it.

Once we add all the imports of Given When and Then




And Give steps inside each given When And Then our StepDefenition class is ready.

7.Create a runner class

Inside our StepDefenition package we can create a ruunerclass. If we have multiple feature files we can execute our cucumber test using the runner class. I have created a Test Runner class like this.

Once we add plugins for reports inside the testrunner class we can generate the reports also. We can add like this

plugin = { "pretty",




213 views0 comments


Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page