CucumberSerenityBDDAPIAutoRunner
CucumberSerenityBDDUIAutoRunner
CucumberSerenityBDDUIReRunner
是我的跑步类躺在一个文件夹。我选择了按字母递增的顺序在最后运行runrunner类。
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(features= “src/test/resources/features/ui/“, glue = “com.xxxx.xxxx.xxxx.features”, plugin = {“pretty”,“rerun:target/failedrerun.txt”}, monochrome = true, tags = “@envr=stagging and @UI”)
public class CucumberSerenityBDDUIAutoRunner {
@WithTag(“envr:stagging”)
public void run_stagging_tests(){}
@WithTag(“envr:prod”)
public void run_production_tests(){}
}
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(features= {“@target/failedrerun.txt”}, glue = “com.xxxx.xxxx.xxxx.features”, plugin = “pretty”, monochrome = true, tags = “@envr=stagging and @UI”)
public class CucumberSerenityBDDUIReRunner {
@WithTag(“envr:stagging”)
public void run_stagging_tests(){}
@WithTag(“envr:prod”)
public void run_production_tests(){}
}
这是我的两个具体的运行器类。
我从gradle运行中收到的错误如下,因为运行程序在原始运行程序之前运行:
com.xxxx.xxxx.xxxx.features.CucumberSerenityBDDUIReRunner > initializationError FAILED
io.cucumber.core.exception.CucumberException: Failed to parse ‘target/failedrerun.txt’
我如何选择正确的顺序?
作为一种解决方案,我创建了一个单独的gradle任务来运行runrunner类,并从源代码中删除了cucumber serenitybdduirerrunner类。
configurations {
cucumberRuntime {
extendsFrom implementation
}
}
task reRun(type: JavaExec, dependsOn:testClasses) {
systemProperties System.getProperties()
systemProperty "cucumber.options", System.getProperty("cucumber.options")
mainClass = "net.serenitybdd.cucumber.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args += [
'--plugin', 'pretty',
'@target/failedrerun.txt',
'--glue', 'com.abc.def.ijk.features']
}
现在我从命令行运行gradle --info clean test reRun aggregate -Denvironment='stagging' -Dtags='envr:stagging' -Dcucumber.options='--tags @envr=stagging'
。
这一次
CucumberSerenityBDDAPIAutoRunner
and
CucumberSerenityBDDUIAutoRunner
类作为test的一部分task和rerun将运行在@target/failedrerun.txt
文件中生成的失败测试用例链接。
Serenity报告只接受在帐户(即)中运行的最新测试用例如果它作为rerun任务的一部分运行,则为rerun。
p。S:我们可以在build.gradle
文件tasks.test {
finalizedBy reRun
}
则旧的gradle --info clean test aggregate -Denvironment='stagging' -Dtags='envr:stagging' -Dcucumber.options='--tags @envr=stagging'
命令也可以工作。