Skip to content
Advertisement

Can’t run testng.xml in Cucumber-Maven(TestNG)

In eclipse IDE, I have created a basic cucumber framework by using Maven project.

I have added all the dependencies required in pom.xml.For TestNG plugin added below dependencies.

JavaScript

But ‘TestNG Suite’ option was not coming in preferences,so installed TestNG through Help->Install New Software.

Framework is having feature file(scenario is described),stepdefinitions(code/logic given) and runner class(To map feature with stepdefinitions file and run it).

Runner class :

JavaScript

Like this I have one runner class for each module(End to End scenario)

Ex :

  • Login, go to product page and logout

  • Login,generate report and logout

I am trying to run these runner class by testng.xml file

testng.xml file

JavaScript

But its throwing below error

Output screen shot

Advertisement

Answer

Issue was because of incompatible junk jars stored in maven repositeries.

Please follow below steps

  1. Clean old properties/maven dependencies(Open command prompt from yours project directory and run below commands)
    • mvn eclipse:clean
    • mvn eclipse:eclipse -Dwtpversion=2.0
  2. Download below cucumber jar files and add in your project(don’t add it in pom directly)

    JavaScript
  3. Make sure that You have already TestNG library into project

  4. Add below cucumber-testng dependencies in pom.xml file

    JavaScript
  5. Extend runner class with AbstractTestNGCucumberTests

JavaScript
  1. Execute with below testng.xml file
JavaScript

Thanks!

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement