rubycucumberrakefiletest-reporting

Cucumber test report from Rakefile


I have a set of Ruby/Cucumber tests. All tests run successfully when run in an IDE.

When I execute tests using this CLI command, the tests run and a test report is generated.

$ cucumber --format progress --format html --out=features_report.html -r features --tags '@this or @that' features

I need to execute the tests from a Rakefile in order to run tests in parallel. I can run them calling the Rakefile below with rake local


desc 'Run the functional test suite locally'
  task :local do

test_args = ["-n", '1', 
             "-o" "-t '@this or @that'",
             "--type", 
             "cucumber", 
             '--',
             '-f',
             'progress', 
             '--',
             'features',]

    ParallelTests::CLI.new.run(test_args)
  end

But I can't figure out where the extra options/arguments that generate a test report go.

If I group the report bits in the Rakefile as they are in the working CLI command

             'progress',
              '-f',
              'HTML', 
             '--out',
             'first.html',

I get this error:

Error creating formatter: HTML (LoadError)

Or, if I do this "-o" "-t '@this or @that' --out first.html --format HTML",

I get this:

All but one formatter must use --out, only one can print to each stream (or STDOUT) (RuntimeError)

Where in the test_args do the arguments that generate a test report go and what do they look like?

Thanks in advance.


Solution

  • You can create profile in the cucumber.yml file and pass the arguments under profile as shown below.

    default:
      --no-source --no-color
      --format progress --format html --out=features_report.html
    

    Now run your rake task as is, cucumber will pick the arguments from cucumber.yml file and generates the report.