How to save Cucumber test results to a file

亡梦爱人 提交于 2019-12-12 10:49:10

问题


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 cucumber directly and use -o. From 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.
    
  • Run rake with CUCUMBER_OPTS="-o whateverfile", i.e.

    CUCUMBER_OPTS="-o whateverfile" rake cucumber # assuming you're using a Bourne family shell
    

    or

    rake CUCUMBER_OPTS="-o whateverfile" cucumber
    
  • Edit lib/tasks/cucumber.rake and add

    t.cucumber_ops = '-o whateverfile'
    

    to one or more of the Cucumber::Rake::Tasks

  • Or just redirect the output of the cucumber command 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!