Search code examples
jenkinsruby-on-rails-6

Setup to create junit xml reports for Jenkins from rails 6 default test runner?


The ci_reporter_minitest gem was very helpful for this when the rake binary was the command to use to start the test runner. I want to use the rails binary vs the rake binary for rails 6.

I'm open to other solutions not using ci_reporter.

I'm failing to get the ci_reporter_minitest gem to work with the rails binary that kicks off running minitest for rails 6. Also, I haven't succeeded yet in finding any posts or questions referencing this problem.

I looked into just using the rake binary for the ci server, but didn't find a working approach there either.

Here's a config I tried that does run the ci:setup task (removing any previous test/report directory) and does run the tests, but doesn't generate the xml output. I did have this working fine with rails 4.2

#lib/tasks/test_tasks.rake
require 'ci/reporter/rake/minitest'

task :minitest => 'ci:setup:minitest'
namespace :test do
  task :something => 'test:prepare' do
    $: << "test"
    Rake::Task['ci:setup:minitest'].invoke
    test_files=FileList['test/models/something.rb']
    Rails::TestUnit::Runner.run(test_files)
  end
end

$> bundle exec rails test:something

Solution

  • I did have success switching to minitest-reporters gem.