问题
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?
回答1:
Either
Run
cucumberdirectly and use-o. Fromcucumber --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.Run
rakewithCUCUMBER_OPTS="-o whateverfile", i.e.CUCUMBER_OPTS="-o whateverfile" rake cucumber # assuming you're using a Bourne family shellor
rake CUCUMBER_OPTS="-o whateverfile" cucumberEdit lib/tasks/cucumber.rake and add
t.cucumber_ops = '-o whateverfile'to one or more of the
Cucumber::Rake::TasksOr just redirect the output of the
cucumbercommand yourself:cucumber > whateverfile
-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.
In case it matters, I'm using Ruby Cucumber 2.3.2.
来源:https://stackoverflow.com/questions/35410895/how-to-save-cucumber-test-results-to-a-file