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;

    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:

intellij file structure

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:

enter image description here

  • Have you tried with io.cucumber.core.cli.Main??
    – Mate Mrše
    Dec 3, 2020 at 16:13
  • @MateMrše yes, I have this defined as Main class in the test runner
    – Steerpike
    Dec 4, 2020 at 9:21

1 Answer 1


Your java is defined as a folder and not package try defining it as package and calling java.uk.co...

if you see the folder color scheme , it shows that green means the folder is test source ;


if you scroll down you can see its not java but test folder needs to be green color. I am not sure how this is done in intellij

This is my project structure :

enter image description here

you can see that after src project everything else is a package. Eclipse project view shows project structure test>java>step definition as test.java.stepdefinition as they are defined as package

and in my runner :

enter image description here

  • do you mean src/test/java? I have that defined as a Test Sources Root necessarily
    – Steerpike
    Dec 3, 2020 at 14:03
  • Could you try java.uk. and so on just add java infront and see what's happening
    – PDHide
    Dec 3, 2020 at 14:06
  • Sorry test.java.uk
    – PDHide
    Dec 3, 2020 at 14:09
  • thank you. I've just found added to the question with some more information I think is pertinent
    – Steerpike
    Dec 3, 2020 at 14:12
  • @Steerpike i added my project structutre that works
    – PDHide
    Dec 3, 2020 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.