如何为黄瓜报告添加时间戳

时间:2019-03-27 08:41:47

标签: automated-tests cucumber bdd cucumber-jvm cucumber-junit

如何在Cucumber-JVM中为测试运行开始/结束以及方案开始/结束向HTML报告添加时间戳?

是否可以将Cucumber选项添加到RunWith JUnit运行器?

2 个答案:

答案 0 :(得分:0)

使用最新的黄瓜版本,您可以在json报告中获得每种情况的开始时间戳,如下所示:

"elements": [
  {
    "start_timestamp": "2019-11-18T11:06:15.606Z",
  ....
  }

答案 1 :(得分:0)

很简单!!!!!!

在插件com.cucumber.listener.ExtentCucumberFormatter中不要提及任何文件夹路径。

示例:

plugin = {“ pretty”,“ html:FeaturesReport”,“ html:target / site / cucumber-pretty”,“ json:target / cucumber.json”,

  "com.cucumber.listener.ExtentCucumberFormatter:",

  },
  1. 运行项目并刷新它。
  2. 检查报告将在默认文件夹输出中生成/与系统时间一起运行/report.html

如果要在带有时间戳的指定路径中生成报告

只需执行以下步骤即可。

  1. goto maven依赖项。

  2. 搜索cucumber-extentsreport.jar

  3. 扩展jar并选择com.cucumber.listener包

  4. 复制ExtentProperties类中的整个代码

  5. 右键单击包装,并使用ExtentProperties名称创建新的枚举

  6. 然后将ExtentProperties类代码粘贴到创建的枚举中。

  7. 在下面的方法中搜索

ExtentProperties(){this.reportPath =“输出” + File.separator +“ Run_” + System.currentTimeMillis()+ File.separator +“ report.html”; this.projectName =“默认”; }

8。使用以下代码替换

String timeStamp = new SimpleDateFormat(“ yyyy.MM.dd.HH.mm.ss”)。format(new Date());

字符串userDir = System.getProperty(“ user.dir”);

ExtentProperties()

{

this.reportPath =“ Extent_Reports” + File.separator +“” + timeStamp.replace(“:”,“”)。replace(“。”,“ _”)+ File.separator +“ Execution report.html “; this.projectName =“默认”;

}

  1. 运行项目,然后刷新项目。

10.check报告将在指定的路径中生成名称。

Extent_Reports / _2020_06_16_19_14_07 / Execution report.html

如有任何疑问,请发表评论