我有一些可以从控制台运行的 Cucumber 测试
rake cucumber
是否有将测试结果存储到文本文件的命令行选项?
最佳答案
要么
直接运行
cucumber
并使用-o
。来自cucumber --help
:-o, --out [FILE|DIR] Write output to a file/directory instead of STDOUT. This option applies to the previously specified --format, or the default format if no format is specified. Check the specific formatter's docs to see whether to pass a file or a dir.
使用
CUCUMBER_OPTS="-o whateverfile"
运行rake
,即CUCUMBER_OPTS="-o whateverfile" rake cucumber # assuming you're using a Bourne family shell
或
rake CUCUMBER_OPTS="-o whateverfile" cucumber
编辑 lib/tasks/cucumber.rake 并添加
t.cucumber_ops = '-o whateverfile'
一个或多个
Cucumber::Rake::Task
或者自己重定向
cucumber
命令的输出:cucumber > whateverfile
-o
与重定向略有不同:它总是将“进度”输出打印到屏幕。如果您不指定格式,它会将默认的“漂亮”格式放入文件中。如果您这样做(例如 cucumber -f html -o whateverfile
),它会将您指定的格式放入文件中。
以防万一,我使用的是 Ruby Cucumber 2.3.2。
关于ruby-on-rails - 如何将 Cucumber 测试结果保存到文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35410895/