I have the following Feature File which is grayed out so I cannot run it from an IntelliJ Run configuration, nor from the right click context in the Feature File, though it runs fine from the Run.java
runner:
Feature: A Test feature
Scenario: a test scenario
Given a test scenario
Running from this context gives: Error: Could not find or load main class cucumber.api.cli.Main
The following runner class:
package uk.co.mytests.steps;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"src/test/resources/features"},
glue = {"uk.co.mytests.steps"},
plugin = {"pretty", "html:target/cucumber", "json:build/cucumber-
test.json", "junit:build/cucumber.xml"})
public class Run {
}
The following StepDefinition class:
package uk.co.mytests.steps;
import io.cucumber.java.en.Given;
public class MyStepdefs {
@Given("a test scenario")
public void aTestScenario() {
System.out.println("My first Given step");
}
}
The following dependencies in my gradle.build
:
compile group: 'io.cucumber', name: 'cucumber-core', version: '6.8.1'
testImplementation 'io.cucumber:cucumber-java:6.8.1'
testCompile group: 'io.cucumber', name: 'cucumber-junit', version: '6.8.1'
And the following file structure in IntelliJ:
And the following IntelliJ plugins Cucumber for Java
, Gherkin
I believe I may have the wrong Cucumber Main on the classpath as I think it should be io.cucumber.core.cli.Main, though my run configuration has this selected: