talira

SimpleCov

Code coverage for Ruby with a powerful configuration library and automatic merging of coverage across test suites

open sourceMITself-hostablefree

SimpleCov measures code coverage for Ruby using Ruby's built-in Coverage library, and turns the results into an HTML report and JSON, with filters, groups and line and branch thresholds that fail the suite. It merges results across test suites, processes and CI machines, and works with any test framework, including RSpec, Minitest and Cucumber. Version 1.x adds a simplecov command for patch coverage of a git diff, the tests that cover each line, running only affected tests, per-file ratchets, coverage history and dead code found by oneshot coverage in production, and it can cover ERB, Haml and Slim views.

Problems it solves

  • how much of my Ruby code do the tests actually run?
  • fail CI when test coverage drops below 90 percent
  • show which lines and branches of my Rails app no test runs, in a report I can browse
  • merge coverage from unit tests, browser tests and parallel CI workers into one number
  • check that the lines changed in this pull request are covered by tests
  • find code that neither production traffic nor the tests ever run, so we can delete it
  • which test covers this line of code?
  • run only the tests that touch the files I changed
  • measure test coverage of ERB, Haml and Slim view templates, not only Ruby files
  • stop each legacy file's coverage from sliding back without one global minimum for every file
  • make a coverage badge for the README without signing up for a badge service
  • find tests that only cover lines other tests already cover
  • export Ruby coverage as JSON for Codecov, Coveralls or another tool to read

Features

  • line and branch coverage from Ruby's Coverage library
  • HTML and JSON formatters built in, more as gems
  • automatic merging across test suites, processes and machines
  • minimum, maximum drop and per-file missed-line thresholds that fail the suite
  • filters, groups and profiles (a built-in rails profile)
  • track_tests: which test covers each line
  • simplecov patch: coverage of a git diff, with a minimum
  • simplecov affected: run only the tests that touch changed code
  • oneshot coverage in production and simplecov dead-code
  • view coverage for ERB, Haml and Slim
View 3 more
  • per-file ratchet baseline and run history
  • watch, show, status, uncovered and badge commands
  • redundant test detection

Capabilities

Has an APIplan not known
Has a command line toolplan not known
Takes pluginsplan not known

Alternatives

The same job

These do what SimpleCov does.

  1. Codecov More than just code coverage.
  2. pytest-cov Pytest plugin for measuring coverage
  3. Coveralls We help you deliver code confidently by showing which parts of your code aren't covered by tests.

Compare SimpleCov with the top 3