Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rerun.txt in Cucumber refers to classpath instead of Feature folder

I'm running Cucumber tests (with Maven, in Jenkins) and outputting failed scenario's to target/rerun.txt, as per these instructions: https://github.com/cucumber/cucumber-jvm/issues/890

It creates the rerun.txt and it inputs failed scenario's, but enters them as: features/name.feature:2. The rerun then tries to run them as classpath/name.feature, and fails to see they are in src/test/resources/features.

If I put the features files in the classpath instead, I get an inconsistent filters error (probably because I'm using tags in the first call and the text in the second call).

How to get Cucumber to either output the correct path for features, or to get it to find the features based on the rerun.txt?

The error:

Running com.xxx.cucumber._RunCukesTest Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.002 sec <<< FAILURE!

initializationError(com.xxx.cucumber._RunCukesTest) Time elapsed: 0 sec <<< ERROR!

java.lang.IllegalArgumentException: Neither found on file system or on classpath: Not a file or directory: classpath\SubFolder\Test1.feature,

No resource found for: classpath:SubFolder/Test1.feature

Additional info: All initial calls to tests are done via tags. All features are in subfolders in classpath/src/test/resources/features This test has to run in Jenkins, automatically, every day.

The first run uses this:

@RunWith(Cucumber.class)
@CucumberOptions(
    strict = false,
    features={"src/test/resources/features/"},
    snippets=SnippetType.CAMELCASE, 
    plugin = { "pretty", "json:target/cucumber-reports/test-report.json", "html:target/cucumber-reports",
            "rerun:target/rerun.txt"})
public class RunCukesTest {
}

The second run of failed scenario's uses this:

@RunWith(Cucumber.class)
@CucumberOptions(
    strict = false,
    features={"@target/rerun.txt"},
    snippets=SnippetType.CAMELCASE, 
    plugin = {"pretty", "json:target/cucumber-reports/test-report.json", "html:target/cucumber-reports"})
public class _RunCukesTest {
}
like image 454
Laharya Avatar asked Feb 01 '26 02:02

Laharya


1 Answers

Change the feature file location of first test runner to features = "." This will make 'rerun.txt' to be updated with correct path to the feature file.

like image 104
Jobin John Avatar answered Feb 02 '26 15:02

Jobin John