Setup Selenium Java Maven Project with Cucumber And TestNG

In this tutorial, you will learn how to setup Selenium Cucumber Java project with TestNG from scratch.


1. Java is installed on Windows (Follow Here)

2. Maven is installed on Windows (Follow Here)

3. IntellijIdea is installed on Windows (Follow Here)

Steps to Setup Selenium Cucumber Java Framework with TestNG:

1. Launch IntellijIdea and click on New Project.

2. Select Maven as Project type and select a java version in Project SDK.  Click on Next.

3. Enter a name for the project (SampleProject) and click on Finish.

4. Once the project setup is completed. Open the pom.xml file

5. Goto and search for the following dependencies.

– selenium-java

– cucumber-java

– cucumber-core

– cucumber-testng

– testng

6. Select the latest version of the dependency and copy the details within <dependency></dependency>

7. Go back to pom.xml and add all the following dependencies.



8. Go to src/test/java and right click on New -> Package. Enter a new package  “com.example”.

9. Right click on test folder and select New -> Directory. Enter a new directory  “resources”.

10. Right click on resources and select New -> Directory. Enter a new directory  “features”.

11. Right click on com.sample and select New -> Package. Enter a new package  “StepDefintions”.

12.  Right click on the package and click on New -> Java Class. Enter a new class  “”.

13. Enter the following in the class

        plugin = {"pretty",
        features = {"src/test/resources/features"},
        glue = {"com.example.StepDefinitions"}

public class TestRunner extends AbstractTestNGCucumberTests {



14. Right click on the project. Select New -> File.

15. Enter file name as testng.xml in New File dialog box. Click on Enter.

16. Open testng.xml file and paste the below content.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "">
<suite name="Test Suite" verbose="1">
    <test name="Regression Tests">
            <class name="com.example.TestRunner">


17. Add all your Cucumber Feature files under features folder.

18. Add all your Step Definition files under StepDefinitions folder.

19. Right click on testng.xml file and click on Run.

20. Cucumber reports are generated under target folder – cucumber.html & cucumber.json

Watch this video for detailed steps:  Click Here


Bijan Patel

Founder & Creator of QAScript | 12+ years of IT Experience | Full Stack Automation Engineer | Blogger | Trainer

You may also like...

Leave a Reply

Your email address will not be published.