Search code examples
mavencucumbertestngcucumber-jvmcucumber-java

What are the important dependencies needed for Cucumber framework and TestNG integration?


I have created a basic Cucumber framework with the help of Maven project in Eclipse IDE.

I am trying to execute all runner classes by using TestNG suite. In order to do that, I have to add all the dependencies required for Cucumber and TestNG integration in pom.xml file.

Runner class 1

package tests.report.runners;
import cucumber.api.CucumberOptions;
@CucumberOptions(features = "src/test/resources/features",glue= {"tests"},tags= {"@Report"})
public class ReportRunner {

}

Runner class 2

package tests.dashboard.runners;
import cucumber.api.CucumberOptions;
@CucumberOptions(features = "src/test/resources/features",glue= {"tests"},tags= {"@Report"})
public class DashboardRunner {

}

testng.xml

?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="First Suite" parallel="classes">
<test name="Chrome Test" parallel="classes">


<classes>
<class name ="tests.report.runners.ReportRunner"></class>
<class name ="tests.dashboard.runners.DashboardRunner"></class>

</classes> 


</test>
</suite> 

Package structure is here:

framework

However, I am getting this error:

Cannot find class in classpath:\src\test\java\tests\report\runners\ReportRunner.java

How can I debug this?


Solution

  • First you must extend this class AbstractTestNGCucumberTests in your launcher class.

    If the running the test didn't work after extending above class you can create a high level folder and named features. Click on the project add new folder and move your feature file into the folder. And accordingly you have to change feature parameter value of CucumberOptions.