【问题标题】:Get executionId in Maven在 Maven 中获取 executionId
【发布时间】:2020-03-19 11:10:55
【问题描述】:

我在pom.xmlmaven-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 如果您在插件运行中需要一些东西,您必须在&lt;configuration&gt; 中放入一些参数。

标签: java maven cucumber-jvm cucumber-junit maven-failsafe-plugin


【解决方案1】:

如果我理解正确的话,你可以通过执行的参数&lt;summaryFile&gt;&lt;reportNameSuffix&gt;来设置报告文件名。所以只要把名字放在那里。

【讨论】:

  • 我的错,我忘了说我使用的是由 cucumber JSONFormatter 生成的报告。所以&lt;summaryFile&gt;&lt;reportNameSuffix&gt; 不适合,因为它适用于故障安全报告。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-05-10
  • 2016-12-29
  • 2014-03-18
  • 1970-01-01
  • 2021-12-28
  • 2016-08-26
  • 1970-01-01
相关资源
最近更新 更多