diff --git a/.simplecov b/.simplecov index 8a7e572..0f1884e 100644 --- a/.simplecov +++ b/.simplecov @@ -1,3 +1,6 @@ +# Set command name before starting to ensure consistent tracking +SimpleCov.command_name "Unit Tests" + SimpleCov.start do # enable_coverage :branch @@ -12,6 +15,15 @@ SimpleCov.start do track_files "lib/**/*.rb" # Group files by module - add_group "AFSC", "lib/gov_codes/afsc" + + # Add JSON formatter for easier parsing + require "simplecov_json_formatter" + formatter SimpleCov::Formatter::MultiFormatter.new([ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::JSONFormatter + ]) + + # Enable result merging + enable_coverage_for_eval end diff --git a/Gemfile.lock b/Gemfile.lock index c4bdebd..2626d1a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,51 +7,50 @@ GEM remote: https://rubygems.org/ specs: ast (2.4.3) - cgi (0.5.1) date (3.5.1) debug (1.11.1) irb (~> 1.10) reline (>= 0.3.8) docile (1.4.1) - erb (4.0.4) - cgi (>= 0.3.3) + erb (6.0.1) io-console (0.8.2) irb (1.16.0) pp (>= 0.6.0) rdoc (>= 4.0.0) reline (>= 0.4.2) - json (2.16.0) + json (2.18.0) language_server-protocol (3.17.0.5) lint_roller (1.1.0) mini_portile2 (2.8.9) - minitest (5.27.0) - nokogiri (1.18.10) + minitest (6.0.1) + prism (~> 1.5) + nokogiri (1.19.0) mini_portile2 (~> 2.8.2) racc (~> 1.4) parallel (1.27.0) - parser (3.3.10.0) + parser (3.3.10.1) ast (~> 2.4.1) racc pp (0.6.3) prettyprint prettyprint (0.2.0) - prism (1.6.0) + prism (1.8.0) psych (5.3.1) date stringio racc (1.8.1) rainbow (3.1.1) rake (13.3.1) - rdoc (7.0.3) + rdoc (7.1.0) erb psych (>= 4.0.0) tsort regexp_parser (2.11.3) - reissue (0.4.8) + reissue (0.4.9) rake reline (0.6.3) io-console (~> 0.5) - rubocop (1.81.7) + rubocop (1.82.1) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -59,16 +58,16 @@ GEM parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.47.1, < 2.0) + rubocop-ast (>= 1.48.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.48.0) + rubocop-ast (1.49.0) parser (>= 3.3.7.2) - prism (~> 1.4) - rubocop-performance (1.25.0) + prism (~> 1.7) + rubocop-performance (1.26.1) lint_roller (~> 1.1) rubocop (>= 1.75.0, < 2.0) - rubocop-ast (>= 1.38.0, < 2.0) + rubocop-ast (>= 1.47.1, < 2.0) ruby-progressbar (1.13.0) simplecov (0.22.0) docile (~> 1.1) @@ -76,23 +75,23 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.13.2) simplecov_json_formatter (0.1.4) - standard (1.52.0) + standard (1.53.0) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.0) - rubocop (~> 1.81.7) + rubocop (~> 1.82.0) standard-custom (~> 1.0.0) standard-performance (~> 1.8) standard-custom (1.0.2) lint_roller (~> 1.0) rubocop (~> 1.50) - standard-performance (1.8.0) + standard-performance (1.9.0) lint_roller (~> 1.1) - rubocop-performance (~> 1.25.0) + rubocop-performance (~> 1.26.0) stringio (3.2.0) tsort (0.2.0) unicode-display_width (3.2.0) unicode-emoji (~> 4.1) - unicode-emoji (4.1.0) + unicode-emoji (4.2.0) PLATFORMS ruby diff --git a/Rakefile b/Rakefile index 076932b..1fae5ed 100644 --- a/Rakefile +++ b/Rakefile @@ -3,7 +3,11 @@ require "bundler/gem_tasks" require "minitest/test_task" -Minitest::TestTask.create +Minitest::TestTask.create do |t| + # Load test_helper before minitest/autorun to ensure SimpleCov's at_exit + # handler runs AFTER tests complete (at_exit runs in LIFO order) + t.test_prelude = 'require "test_helper"' +end require "standard/rake" diff --git a/test/gov_codes/afsc/enlisted_coverage_test.rb b/test/gov_codes/afsc/enlisted_coverage_test.rb index c1910f6..27cb836 100644 --- a/test/gov_codes/afsc/enlisted_coverage_test.rb +++ b/test/gov_codes/afsc/enlisted_coverage_test.rb @@ -1,5 +1,5 @@ +require "test_helper" require "minitest/autorun" -require_relative "../../../lib/gov_codes/afsc" class EnlistedCoverageTest < Minitest::Test def test_find_with_nil_and_empty diff --git a/test/test_helper.rb b/test/test_helper.rb index abfacaa..aacd5d6 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,10 +1,18 @@ # frozen_string_literal: true +# SimpleCov must be required BEFORE minitest/autorun to ensure proper at_exit order. +# at_exit handlers run in LIFO order, so SimpleCov's report will generate AFTER +# tests complete only if SimpleCov registers its handler first. require "simplecov" if ENV["CI"] + +# Require minitest components before loading our code to avoid circular require warnings. +# minitest/autorun is loaded by the test task, so we only need minitest/spec here. +require "minitest/autorun" +require "minitest/spec" + $LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "gov_codes" require "gov_codes/afsc" -require "minitest/spec" require "debug"