cucumber jvm CucumberException: No features found at []
Asked Answered
I

11

10

In my cucumber -jvm, Maven, junit Setup I have my testRunner file as

package com.lebara.testrunner;

import cucumber.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@Cucumber.Options(

glue = {"com.lebara.stepdefs","com.lebara.framework.main", "com.lebara.testrunner"},
features = "C:/Users/sarthak.dayanand/Documents/WebRefreshTest/CukeAutomation/LebaraWebAutomationTest1/src/main/resources",
format = {"pretty", "html:target/cucumber-html-report", "json-pretty:target/cucumber-report.json"},
tags = {"@UserJourney"}

)
public class RunCukesTest {
}

I have my feature file in the above mentioned directory.

If I run it, I get the following exception:

cucumber.runtime.CucumberException: No features found at [C:/Users/sarthak.dayanand/Documents/WebRefreshTest/CukeAutomation/LebaraWebAutomationTest1/src/main/resources/cucumber]...

If I remove the "features" option in the testrunner, it tries to look for feature files in the same directory as my testrunner.java

cucumber.runtime.CucumberException: No features found at [com/lebara/testrunner]

And if I put the feature files there, it works.

My question is why is my feature file not being picked up from my previous location, which I thought to be the default file structure for cucumber - maven setup.

How do I make it pick up from there? Help appreciated.

Ignazio answered 21/1, 2013 at 11:32 Comment(0)
T
19

Where exactly are your test runner and feature files? I've got the following setup which works perfectly:

src/test/
    java/
        com/mypackage/
            TestRunner.java
            StepDefinition.java
    resources
        com/mypackage/
            fancy.feature

The Maven/Cuke conventions will have the tests executed from the tests/java directory and the feature files found in the test/resources directory. My test runner is basically the same as yours but with less options:

import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@Cucumber.Options(format = {"pretty"})
public class TestRunner { }

Hope this helps if you hadn't already found an answer.

Tiffanytiffi answered 11/2, 2013 at 6:22 Comment(1)
changing from ".features" to ".feature" fixed it for me; thanksAltazimuth
B
6

I have a setup similar to yours (not using the Maven/Cucumber conventions). In my options, I don't specify the path from root, but from the project's source folder where the features are held. It makes sense, since otherwise the tests would only be runnable from your machine.

In your case, I think it should be:

features = "src/main/resources"
Broomcorn answered 24/8, 2013 at 16:35 Comment(0)
E
3

Just add features = { "classpath:features/feature.feature"}, and the feature must under test/resources/features/feature.feature.

    @CucumberOptions(
        format = {"pretty", "html:target/html"},
        features = {"classpath:features/feature.feature"},
        snippets = SnippetType.CAMELCASE

Note classpath.

When you compile your code if you are using maven open up target/test-classes/features and you will see feature.feature

Ellord answered 30/1, 2017 at 12:8 Comment(0)
G
3
//Removing the space between "**classpath**" and "**:com/**" helped.

@RunWith(Cucumber.class)
@CucumberOptions(
        features = {"classpath:com/tk/feature/"}, //NOTE: NO SPACE
        glue = {"classpath: com.tk.cucumber"}, 
        plugin = {
                "pretty", 
                "html:build/reports/cucumber" 
                ,"json:build/reports/cucumber-tests/test.json"}
        )
public class RunAPITests {}
Graehl answered 16/3, 2020 at 16:16 Comment(0)
I
0

If you are providing the complete path of the feature file i.e.

"C:/Users/sarthak.dayanand/Documents/WebRefreshTest/CukeAutomation/LebaraWebAutomationTest1/src/main/resources" as in your query, try again by replacing the '/' character with '\\'(double back slash) as below.

"C:\\Users\\sarthak.dayanand\\Documents\\WebRefreshTest\\CukeAutomation\\LebaraWebAutomationTest1\\src\main\\resources\\abc.feature"

Ingress answered 24/7, 2014 at 7:31 Comment(0)
K
0

This is a git repo which uses the latest cucumber version : Cucumber- Example

Clone this repo and run it in your local machine. The @Given is defined and it should pass. The @Then and @When should be shown as undefined.

This is how the output for it should look : Output for the Belly feature

Use the structure mentioned : src / test / java/ io /cucumber / {Step definitions java and run cucumber test files here} src /test / resources/ io/ cucumber / {feature files here}

You can run the gradle build using ./gradlew clean build and the cucumber test using ./gradlew clean test --info

If this works, then use the same format in your project.

Kronfeld answered 2/8, 2019 at 5:56 Comment(0)
O
0

Just changing .Feature to .feature the problem got resolved for me.

Also make sure the path for feature is righly mention in CucumberOptions as per your feature folder

Some of the online tutorial have mentioned .Feature which brings this problem

so changing the case will solve this problem

enter image description here

Omura answered 27/1, 2020 at 12:13 Comment(0)
C
0

There is another instance in which 'Feature Not Found' error occurs. I am posting the solution under this answer as there is no similar question.

I got this error when trying to run the Runner file first time after setting up Cucumber project in Maven. The solution i found was as follows: Go to the folder in which the 'feature' file is present in Windows Explorer. Check the size of the feature file you are trying to run. If the size is '0' KB, it will show the 'Feature Not Found' error. Make some changes to file until a value greater than zero is displayed. Run again after making changes.

Claro answered 4/9, 2020 at 12:29 Comment(1)
I have same error with feature file size as non-zero.Columnist
T
0
@RunWith(Cucumber.class)
@CucumberOptions(
    features = {"src/main/resources/cucumber/features"},//your feature path
    tags = "not @Wip",
    glue = {"classpath:steps"},
    plugin = {"pretty", "html:target/cucumber/html"})

You must set the feature directory correctly

Thumbnail answered 28/1, 2022 at 9:54 Comment(0)
A
0

Right click on your runner file and select runAs then click on run-configuration. From there, go to your feature file—as shown in the image—and configure your feature path there. Finally, run again. It should solve your problem.

enter image description here

Aleut answered 27/9, 2023 at 7:50 Comment(0)
S
-4

By putting the feature file under src/test/java where the runner and steps file or by putting it under src/main/java the problem will get resolved.

Shrove answered 7/4, 2017 at 11:29 Comment(1)
Don't put test code under src/main. That folder generally contains code that goes to production and you don't want test code going to production.Youngster

© 2022 - 2024 — McMap. All rights reserved.