Cucumber 中的 Rerun.txt 是指类路径而不是 Feature 文件夹

Lah*_*rya 3 java cucumber maven jenkins

我正在运行 Cucumber 测试(使用 Maven,在 Jenkins 中)并将失败的场景输出到 target/rerun.txt,按照以下说明:https : //github.com/cucumber/cucumber-jvm/issues/890

它创建 rerun.txt 并输入失败的场景,但将它们输入为: features/name.feature:2。然后重新运行尝试将它们作为 classpath/name.feature 运行,但未能看到它们在 src/test/resources/features 中。

如果我将功能文件放在类路径中,则会出现不一致的过滤器错误(可能是因为我在第一次调用中使用了标签,而在第二次调用中使用了文本)。

如何让 Cucumber 输出正确的特征路径,或者让它根据 rerun.txt 找到特征?

错误:

运行 com.xxx.cucumber._RunCukesTest 测试运行:1,失败:0,错误:1,跳过:0,时间:0.002 秒 <<< 失败!

初始化错误(com.xxx.cucumber._RunCukesTest)经过的时间:0秒<<<错误!

java.lang.IllegalArgumentException:在文件系统或类路径上均未找到:不是文件或目录:classpath\SubFolder\Test1.feature,

找不到资源:classpath:SubFolder/Test1.feature

附加信息:所有对测试的初始调用都是通过标签完成的。所有功能都在 classpath/src/test/resources/features 的子文件夹中。这个测试必须每天在 Jenkins 中自动运行。

第一次运行使用这个:

@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 {
}
Run Code Online (Sandbox Code Playgroud)

失败场景的第二次运行使用这个:

@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 {
}
Run Code Online (Sandbox Code Playgroud)

小智 8

将第一个测试运行器的功能文件位置更改为features = "." 这将使“rerun.txt”更新为功能文件的正确路径。