How to create Runner class in Cucumber using Java

Cucumber is a BDD-based tool that works well with selenium and many other tools. Here we have a sample Runner class to be used with Selenium using JUnit.

Test Runner file is required to execute the Step definition methods written for the feature file. Check out a sample Test runner class in cucumber.

Runner Class in cucumber using Java and JUnit
/**
 * This is a sample Test Runner class using junit 
 * Values an be provided as per the requirements
 */

package runner;

import org.junit.runner.RunWith;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;

@RunWith(Cucumber.class)
@CucumberOptions(
	features = {"src/test/resources/features"},
	glue= {"stepsdefs","support"},
	tags= "P2"
	plugin= {"html:target/cucumber-html-report", "json:target/cucumber-json-report.json"} ,
	monochrome= true,
	strict= true,
	dryRun= false

	)
public class TestRunner {

}

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.