-1

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
Avinmita
  • 69
  • 1
  • 9
  • What problem are you specifically having with this integration? I wonder if it would help to be more specific. Are you getting an error? – halfer Dec 29 '18 at 10:54
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Dec 29 '18 at 10:54
  • Right, that's much better, thanks - I have added that to your question. – halfer Dec 29 '18 at 11:53

2 Answers2

0

I think you are not extending the testNG class in the Runner class which might me the reason as JVM wont know it has to use TestNG.

public class ReportRunner extends AbstractTestNGCucumberTests{

}

Try using the above statement for both your runners and then try.

Neha
  • 316
  • 1
  • 4
  • 16
0

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.

Nael Marwan
  • 1,030
  • 1
  • 13
  • 32