CUCUMBER-JVM AND TestNG
The answer is yes you can.
A lot of frameworks are developed using TestNG and you would want such frameworks to drive Cucumber-jvm. Therefore, the following steps below will allow you use Cucumber successfully with TestNG.
Step 1. Add the following dependency into your Maven pom.xml file.
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>1.2.2</version>
</dependency>
Step 2. Extend your class running your JUnit Runner with AbstractTestNGCucumberTests. For example:
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import cucumber.api.testng.AbstractTestNGCucumberTests;
@RunWith(Cucumber.class)
@CucumberOptions (
monochrome = true,
features = "src/test/java/features",
plugin = {"pretty", "html:target/cucumber-html-report"},
//glue = " ",
tags = "@testdiary"
)
public class CukesRunnerTest extends AbstractTestNGCucumberTests {
}
Step 3. Insert your test package to run into your testng.xml file. For example:
<test name="Test diary">
<packages>
<package name="cucumberTraining"/>
</packages>
</test>
Example of a Cucumber test running on TestNG
You can download this Cucumber-jvm TestNg framework from the Testdiary Github.
Click: Cucumber-jvm TestNG Framework
This should solve your problem
Happy testing!!!
Recent Comments