如何将 Cucumber 测试结果保存到文件中 [英] How to save Cucumber test results to a file
问题描述
我有一些可以从控制台运行的 Cucumber 测试
I have some Cucumber tests that can be run from console with
rake cucumber
是否有将测试结果存储到文本文件的命令行选项?
Is there a command line option to store test results to a text file?
推荐答案
要么
直接运行
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 不管文件"
运行 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 并添加
Edit lib/tasks/cucumber.rake and add
t.cucumber_ops = '-o whateverfile'
到一个或多个Cucumber::Rake::Task
s
或者只是自己重定向cucumber
命令的输出:
Or just redirect the output of the cucumber
command yourself:
cucumber > whateverfile
-o
与重定向有点不同:它总是将进度"输出打印到屏幕上.如果您不指定格式,它会将默认的漂亮"格式放入文件中.如果你这样做(例如 cucumber -f html -owhateverfile
),它会将你指定的格式放入文件中.
-o
is a little different than redirecting: it always prints the "progress" output to the screen. If you don't specify a format it puts the default "pretty" format in the file. If you do (e.g. cucumber -f html -o whateverfile
) it puts the format you specify in the file.
以防万一,我使用的是 Ruby Cucumber 2.3.2.
In case it matters, I'm using Ruby Cucumber 2.3.2.
这篇关于如何将 Cucumber 测试结果保存到文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!