Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save Cucumber test results to a file

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?

like image 381
Pavel Oganesyan Avatar asked Feb 15 '16 13:02

Pavel Oganesyan


People also ask

How do I get Cucumber report link?

Cucumber Reports You can then access them from your browser, where they will be rendered using the same HTML formatter that would be used on the desktop. The public beta is available at https://reports.cucumber.io where you will find a sample report and an FAQ.

How do I get Cucumber report in Intellij?

From the main menu, select Run | Edit Configurations. or press Alt+Insert and select Cucumber Java from the list. After that, you can complete the configuration using the options on the right. For the description of each option, refer to Run/Debug configuration: Cucumber Java.

Which plugin helps to generate reports in Cucumber?

Cucumber uses reporter plugins to produce reports that contain information about what scenarios have passed or failed.


1 Answers

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.

like image 93
Dave Schweisguth Avatar answered Oct 12 '22 23:10

Dave Schweisguth