minitest-json-reporter
A Minitest reporter plugin that emits test results as JSON.
Installation
Add the gem to your application's Gemfile:
group :test do
gem "minitest-json-reporter"
endThen install:
bundle installUsage
Load the plugin from your test helper:
require "minitest/json_reporter"You can then enable JSON output with the existing CLI flag:
rails test --json
ruby -Ilib:test test/example_test.rb --jsonFor runners that need to work with Rails 8, prefer the environment variable. Rails 8 loads test files after
Minitest starts parsing CLI options, so custom flags loaded from test_helper.rb are too late, but environment-based
activation works:
MINITEST_JSON=1 rails test
MINITEST_JSON=1 ruby -Ilib:test test/example_test.rbYou can also enable the reporter from Ruby:
require "minitest/json_reporter"
Minitest::JsonReporter.use!Development
Run tests with:
bundle exec rake testLicense
The gem is available as open source under the terms of the MIT License.