我正在运行 Cucumber 测试(在 Jenkins 中使用 Maven)并将失败的场景输出到 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 找到特征?
错误:
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
附加信息: 所有对测试的初始调用都是通过标签完成的。 所有功能都在 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 {
}
第二次失败的场景使用这个:
@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 {
}
最佳答案
将第一个测试运行器的功能文件位置更改为 features = "."
这将使“rerun.txt”更新为功能文件的正确路径。
关于java - Cucumber 中的 Rerun.txt 指的是类路径而不是 Feature 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36770893/