如何生成带有时间戳的黄瓜报告名称? [英] How to generate cucumber report name with a timestamp?

查看:123
本文介绍了如何生成带有时间戳的黄瓜报告名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工具,每天运行一个黄瓜的功能,但问题是报告总是与前一个相同的名称,昨天的报告可以被当前的覆盖。
我的cucumber.yml看起来像这样:

I have a tool that runs a cucumber features each day, but the problem is that report always has the same name as previous and yesterdays report can be overriden by the current. My cucumber.yml looks like this:

...
default-report: FIG_NEWTON_FILE=default.yml --color --format html --out results/report.html
...

我有一个想法重命名以前生成的报告钩子和移动到一些存档文件夹,但这看起来很复杂的这样小的事情。有没有办法生成黄瓜报告名称与一些时间戳而不是hardcode它在cucumber.yml?

I have an idea of renaming previously generated reports in hooks and move them to some archive folder, but that looks way to complicated for such small thing. Is there a way to generate cucumber report name with some timestamp instead of hardcode it in the cucumber.yml?

推荐答案

cucumber.yml文件由ERb预处理。因此您可以使用ruby代码在cucumber.yml文件中生成值随你便。

The cucumber.yml file is preprocessed by ERb.So you can use ruby code to generate values in the cucumber.yml file as you like.

要在报告文件名中包含时间戳,可以执行以下操作:

To have a timestamp in your report file name, you can do something like below:

default-report: FIG_NEWTON_FILE=default.yml --color --format html --out results/<%= Time.now.strftime("%Y%m%d-%H%M%S") %>-report.html

这篇关于如何生成带有时间戳的黄瓜报告名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆