如何在Cucumber-JVM中为测试运行开始/结束以及方案开始/结束向HTML报告添加时间戳?
是否可以将Cucumber选项添加到RunWith JUnit运行器?
答案 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:",
},
如果要在带有时间戳的指定路径中生成报告
只需执行以下步骤即可。
goto maven依赖项。
搜索cucumber-extentsreport.jar
扩展jar并选择com.cucumber.listener包
复制ExtentProperties类中的整个代码
右键单击包装,并使用ExtentProperties名称创建新的枚举
然后将ExtentProperties类代码粘贴到创建的枚举中。
在下面的方法中搜索
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 =“默认”;
}
10.check报告将在指定的路径中生成名称。
Extent_Reports / _2020_06_16_19_14_07 / Execution report.html
如有任何疑问,请发表评论