Cucumber Dependency In Maven

Teach Yourself Test Automation
2 min readApr 17, 2022

--

Day 61- Teach Yourself Test Automation

how to add cucumber dependency in maven

In the set up Maven of your project to run Cucumber automation test cases, you need to add the two cucumber dependencies below into your Maven project;

  • Cucumber-Java
  • Cucumber JUnit

Cucumber Dependencies In Maven

With Maven projects we need to download required cucumber Jars through adding/updating dependencies within the POM file.

For a Java project you could add Jars directly to Java Build Path.

Do not add Cucumber Jars directly to your project, hard coding these Jars within your Maven project setup is not best practice.

The best practice is to update dependencies in you POM file with Cucumber Jars from the Maven repository.

With this setup above, everyone within a team would be using or referencing the same set of Jars within that a project.

How To Add Cucumber Dependency In Maven

Every Maven project has a POM.xml file.

  1. Open up the POM.xml file.
  2. Access Maven repository via google (All software Jars stored here)
  3. Within the Maven repository identify the latest/stable Versions of the Cucumber Jars
  4. Copy the dependency information you want to use (Cucumber Java and Cucumber JUnit) from the Maven repository
  5. Add to your POM.xml file within the dependencies section of the code.
  6. Save the Maven project.
  7. Jars will be automatically downloaded from the Maven repository server into your project structure.
Cucumber Dependency In Maven,

Whatever information on Cucumber Jars you provide within your POM.xml file, this is what will be downloaded into your project structure.

As already mentioned, Jars have been automatically downloaded from the Maven repository in your Maven project.

Hope you found this wee blog on how to add Cucumber dependency to Maven helpful.

Next stop, understanding/learning more about the framework.

Originally published: https://teachyourselftestautomation.com/cucumber-dependency-in-maven/

--

--