🕷 software projects

by ryan davis



sitemap

minitest-coverage

Ruby's contemporary test coverage tools all lie. This fixes that.

Ruby’s contemporary test coverage tools all lie.

# create baseline in production mode to force load all models & controllers
% RAILS_ENV=production time ruby -Ilib:. -rcoverage/start -rcoverage/pruner config/environment.rb 
% mv coverage.json baseline.json

# run tests in full or in part:
% minitest_coverage --coverage=baseline.json 'test/unit/**/*_test.rb'
% mv coverage.json coverage.unit.json

% minitest_coverage --coverage=baseline.json 'test/{functional,controllers}/**/*_test.rb'
% mv coverage.json coverage.fun.json

# generate a report
% minitest_coverage_report baseline.json coverage.unit.json coverage.fun.json 

outputs:

uncv  covr% totl : path

 403   4.5%  422 : app/models/option_expense_report/oer_export.rb
 322  11.0%  362 : app/models/certificate_expense.rb
 262   7.4%  283 : app/models/option_expense_report_processor.rb
 237  25.2%  317 : app/controllers/transactions_controller.rb
 209  19.9%  261 : app/models/concerns/excel_sheet.rb
 166  13.1%  191 : app/models/summary_captable.rb
 148  25.3%  198 : app/concerns/formula.rb
 142  10.7%  159 : app/helpers/valuation_reports_helper.rb
 132  33.0%  197 : app/models/public_comp_list.rb
 122  28.7%  171 : app/controllers/permissions_controller.rb
 120  28.1%  167 : lib/importer.rb
 115  36.1%  180 : app/controllers/workflows_controller.rb
 110  46.9%  207 : app/helpers/transactions_helper.rb
 101  35.3%  156 : app/models/ma_comp_list.rb
  97  36.2%  152 : app/models/option_expense_report.rb

[869 lines skipped]

Actual Coverage = 12912 / 24621 = 52.44%

Get The Code

If you just want to use minitest-coverage, you can install it via RubyGems:
gem install minitest-coverage
Fork me on GitHub If you want to hack on minitest-coverage, clone it from GitHub:
git clone git://github.com/seattlerb/minitest-coverage

Latest Activity