1
votes

I need to get rails test published report in XML and HTML since Azure DevOps only accepts this two format. I tried simplecov but it generates .json and HTML format. I also tried simplecov-cobertura but it generates XML only.

I tried the multi-format option for simplecov

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::XMLFormatter])

But it's causing an error uninitialized constant SimpleCov::Formatter::XMLFormatter

What are other options or libraries do u suggest to generate reports coverage for rails?

1

1 Answers

1
votes

It ends up by using 2 libraries to generate the formats I need so I add to gem file

gem 'simplecov-cobertura', require: false
gem 'simplecov', require: false

and in rails_helper

require 'simplecov'
require 'simplecov-cobertura'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::CoberturaFormatter])
SimpleCov.start do
    add_filter '/test/'
    add_filter '/config/'
    add_filter '/vendor/'
    add_group 'Controllers', 'app/controllers'
end

This way generates both xml and html format