【发布时间】:2020-03-19 11:10:55
【问题描述】:
我在pom.xml 的maven-failsafe-plugin 声明中有一个执行部分。
<execution>
<id>execId</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<includes>
<include>**/*LauncherIT.java</include>
</includes>
</configuration>
</execution>
LauncherIT 使用自定义黄瓜跑步者。
@RunWith(CustomCucumber.class)
@io.cucumber.junit.CucumberOptions(
plugin = {"json:target/cucumber.json"}
)
public class LauncherIT {
}
有没有办法在运行时访问 customCucumber.java 中的执行 ID(并获取 "execId" 值)?
我知道可以在执行内部定义一个系统变量并将"execId" 写入其中,但我想准确读取执行ID。
【问题讨论】:
-
执行 ID 仅在 maven 插件中可用......但在您的测试中不可用。问题是:为什么在测试中需要
execId? -
@khmarbaise 因为我正在使用 jenkins,并且在构建之后,黄瓜插件提供了一些结果,这些结果由它们的功能文件命名。一些功能文件运行不止一次(在执行中设置了不同的选项),所以最后我有一些同名的报告,我不知道是什么执行产生了具体的报告。所以,我需要 id 将其添加到默认报告名称中。
-
AFAIK 如果您在插件运行中需要一些东西,您必须在
<configuration>中放入一些参数。
标签: java maven cucumber-jvm cucumber-junit maven-failsafe-plugin