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.
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>1.2.5</version>
</dependency>
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 :
package tests.report.runners;
import cucumber.api.CucumberOptions;
@CucumberOptions(features = "src/test/resources/features",glue= {"tests"},tags= {"@Report"})
public class ReportRunner {
}
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
<?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>
</classes>
</test>
</suite>
But its throwing below error
Advertisement
Answer
Issue was because of incompatible junk jars stored in maven repositeries.
Please follow below steps
- 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
Download below cucumber jar files and add in your project(don’t add it in pom directly)
JavaScript<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
<scope>provided</scope>
</dependency>
Make sure that You have already TestNG library into project
Add below cucumber-testng dependencies in pom.xml file
JavaScript<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>1.2.5</version>
</dependency>
Extend runner class with AbstractTestNGCucumberTests
JavaScriptpackage tests.report.runners;
import org.testng.annotations.Test;
import cucumber.api.testng.AbstractTestNGCucumberTests;
import cucumber.api.CucumberOptions;
@Test
@CucumberOptions(features = "src/test/resources/features",glue= {"tests"},tags=
{"@Report"})
public class ReportRunner extends AbstractTestNGCucumberTests {
}
- Execute with below testng.xml file
JavaScript<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="First Suite" >
<test name="Chrome Test" >
<classes>
<class name ="tests.report.runners.ReportRunner"></class>
</classes>
</test>
</suite>
Thanks!