Skip to content

Commit

Permalink
Add minitest-reporters to get better test output (#1076)
Browse files Browse the repository at this point in the history
* Add minitest-reporters to get better test output

Fixes #1075

* Beef up the formatter config

* linter

* try to store results in Circle

* add a failing test to see if it shows up in circle

* clean up

* Use an ENV var to control the output format

* clean up

* Update test/test_helper.rb

Co-authored-by: Kasper Timm Hansen <[email protected]>

---------

Co-authored-by: Kasper Timm Hansen <[email protected]>
  • Loading branch information
jagthedrummer and kaspth authored Oct 18, 2023
1 parent dfd49f1 commit 336bf24
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 14 deletions.
23 changes: 9 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,9 @@ jobs:
# - run:
# name: Run system tests
# command: bundle exec rails test:system
#
# If you want to gather test results in CircleCI when not running tests in parallel,
# include `minitest-ci` in your Gemfile and uncomment the following step.
# You can access the test results via the "Tests" tab within each build in CircleCI.
#
# - store_test_results:
# path: test/reports

- store_test_results:
path: test/reports

'Minitest with HIDE_THINGS':
parameters:
Expand Down Expand Up @@ -192,13 +188,9 @@ jobs:
# - run:
# name: Run system tests with HIDE_THINGS
# command: HIDE_THINGS=true bundle exec rails test:system
#
# If you want to gather test results in CircleCI when not running tests in parallel,
# include `minitest-ci` in your Gemfile and uncomment the following step.
# You can access the test results via the "Tests" tab within each build in CircleCI.
#
# - store_test_results:
# path: test/reports

- store_test_results:
path: test/reports

'Minitest for Super Scaffolding':
parameters:
Expand Down Expand Up @@ -249,6 +241,9 @@ jobs:
name: 'Run Super Scaffolding Incoming Webhooks Test'
command: bundle exec rails test test/controllers/webhooks/incoming/some_provider_webhooks_controller_test.rb

- store_test_results:
path: test/reports

'System Tests with Cuprite':
parameters:
use-core-repo:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,7 @@ dump.rdb
# Ignore test coverage results generated by simplecov.
/coverage

# Ignore test reports generated by minitest-reporters
/test/reports

# 🚅 add your files to ignore here.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ group :test do
# Helps smooth over flakiness in system tests.
gem "minitest-retry"

# Better test output
gem "minitest-reporters"

# Interact with emails during testing.
gem "capybara-email"

Expand Down
7 changes: 7 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
ansi (1.5.0)
ast (2.4.2)
awesome_print (1.9.2)
aws-eventstream (1.2.0)
Expand Down Expand Up @@ -347,6 +348,11 @@ GEM
mini_mime (1.1.5)
mini_portile2 (2.8.4)
minitest (5.20.0)
minitest-reporters (1.6.1)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
minitest-retry (0.2.2)
minitest (>= 5.0)
msgpack (1.7.2)
Expand Down Expand Up @@ -659,6 +665,7 @@ DEPENDENCIES
knapsack_pro
letter_opener
magic_test
minitest-reporters
minitest-retry
pg (>= 0.18, < 2.0)
postmark-rails
Expand Down
21 changes: 21 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@
require "sidekiq/testing"
Sidekiq::Testing.inline!

require "minitest/reporters"

reporters = []

if ENV["BT_TEST_FORMAT"]&.downcase == "dots"
# The classic "dot style" output:
# ...S..E...F...
reporters.push Minitest::Reporters::DefaultReporter.new
else
# "Spec style" output that shows you which tests are executing as they run:
# UserTest
# test_details_provided_should_be_true_when_details_are_provided PASS (0.18s)
reporters.push Minitest::Reporters::SpecReporter.new(print_failure_summary: true)
end

# This reporter generates XML documents into test/reports that are used by CI services to tally results.
# We add it last because doing so make the visible test output a little cleaner.
reporters.push Minitest::Reporters::JUnitReporter.new if ENV["CI"]

Minitest::Reporters.use! reporters

begin
require "bullet_train/billing/test_support"
FactoryBot.definition_file_paths << BulletTrain::Billing::TestSupport::FACTORY_PATH
Expand Down

0 comments on commit 336bf24

Please sign in to comment.