All Projects → grosser → Single_cov

grosser / Single_cov

Licence: mit
Actionable code coverage.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Single cov

jacoco-report
Github action that publishes the JaCoCo report as a comment in the Pull Request
Stars: ✭ 31 (-79.87%)
Mutual labels:  coverage, code-quality, code-coverage
instrumentation
Assorted pintools
Stars: ✭ 24 (-84.42%)
Mutual labels:  coverage, code-coverage
tarpaulin
📈 GitHub Action for code coverage reporting with tarpaulin
Stars: ✭ 69 (-55.19%)
Mutual labels:  coverage, code-coverage
frankencover.it
Code coverage for iOS and OSX.
Stars: ✭ 102 (-33.77%)
Mutual labels:  coverage, code-coverage
grcov
📈 GitHub Action for code coverage reporting with grcov
Stars: ✭ 96 (-37.66%)
Mutual labels:  coverage, code-coverage
code-coverage-action
GitHub Action that generates code coverage reports
Stars: ✭ 28 (-81.82%)
Mutual labels:  coverage, code-coverage
mutant-swarm
Mutation testing framework and code coverage for Hive SQL
Stars: ✭ 20 (-87.01%)
Mutual labels:  coverage, code-coverage
Undercover
Actionable code coverage - detects untested code blocks in recent changes
Stars: ✭ 574 (+272.73%)
Mutual labels:  coverage, code-quality
Simplecov
Code coverage for Ruby with a powerful configuration library and automatic merging of coverage across test suites
Stars: ✭ 4,362 (+2732.47%)
Mutual labels:  coverage, code-quality
Utplsql
Testing Framework for PL/SQL
Stars: ✭ 402 (+161.04%)
Mutual labels:  coverage, code-coverage
Interrogate
Explain yourself! Interrogate a codebase for docstring coverage.
Stars: ✭ 245 (+59.09%)
Mutual labels:  coverage, code-quality
Coveralls Ruby
Coveralls for Ruby
Stars: ✭ 115 (-25.32%)
Mutual labels:  coverage, code-quality
Cmake Scripts
A selection of useful scripts for use in CMake projects, include code coverage, sanitizers, and dependency graph generation.
Stars: ✭ 202 (+31.17%)
Mutual labels:  coverage, code-coverage
ruby-codacy-coverage
DEPRECATED Post coverage results to Codacy
Stars: ✭ 12 (-92.21%)
Mutual labels:  coverage, code-coverage
Minicover
Cross platform code coverage tool for .NET Core
Stars: ✭ 193 (+25.32%)
Mutual labels:  coverage, code-coverage
Coverlet
Cross platform code coverage for .NET
Stars: ✭ 2,303 (+1395.45%)
Mutual labels:  coverage, code-coverage
Github Action
Coveralls Github Action
Stars: ✭ 214 (+38.96%)
Mutual labels:  code-quality, code-coverage
Skunk
A SkunkScore Calculator for Ruby Code -- Find the most complicated code without test coverage!
Stars: ✭ 228 (+48.05%)
Mutual labels:  code-quality, code-coverage
Altcover
Cross-platform coverage gathering and processing tool set for .net/.net core and Mono
Stars: ✭ 344 (+123.38%)
Mutual labels:  coverage, code-coverage
Bashcov
Code coverage tool for Bash
Stars: ✭ 113 (-26.62%)
Mutual labels:  coverage, code-coverage

Single Cov Build Status coverage

Actionable code coverage.

rspec spec/foobar_spec.rb
......
114 example, 0 failures

lib/foobar.rb new uncovered lines introduced (2 current vs 0 configured)
Uncovered lines:
lib/foobar.rb:22
lib/foobar.rb:23:6-19
  • Missing coverage on every 💚 test run
  • Catch coverage issues before making PRs
  • Easily add coverage enforcement for legacy apps
  • 2-5% runtime overhead on small files, compared to 20% for SimpleCov
  • Branch coverage (disable via branches: false)
  • Use with forking_test_runner for per test coverage
# Gemfile
gem 'single_cov', group: :test

# spec/spec_helper.rb ... load before loading rails / minitest / libraries
require 'single_cov'
SingleCov.setup :rspec

# spec/foobar_spec.rb ... add covered! call to test files
require 'spec_helper'
SingleCov.covered!

describe "xyz" do ...

Minitest

Call setup before loading minitest.

SingleCov.setup :minitest
require 'minitest/autorun'

Unfound target file

# change all guessed paths
SingleCov.rewrite { |f| f.sub('lib/unit/', 'app/models/') }

# mark directory as being in app and not lib
SingleCov::RAILS_APP_FOLDERS << 'presenters'

# add 1-off
SingleCov.covered! file: 'scripts/weird_thing.rb'

Known uncovered

Add the inline comment # uncovered to not be alerted about it being uncovered.

Prevent addition of new uncovered code, without having to cover all existing code.

Alternatively mark how many lines are uncovered:

SingleCov.covered! uncovered: 4

Verify all code has tests & coverage

# spec/coverage_spec.rb
SingleCov.not_covered! # not testing any code in lib/

describe "Coverage" do
  it "does not allow new untested code" do
    # option :tests to pass custom Dir.glob results
    SingleCov.assert_used
  end

  it "does not allow new untested files" do
    # option :tests and :files to pass custom Dir.glob results
    # :untested to get it passing with known untested files
    SingleCov.assert_tested
  end
end

Automatic bootstrap

Run this from irb to get SingleCov added to all test files.

tests = Dir['spec/**/*_spec.rb']
command = "bundle exec rspec %{file}"

tests.each do |f|
  content = File.read(f)
  next if content.include?('SingleCov.')

  # add initial SingleCov call
  content = content.split(/\n/, -1)
  insert = content.index { |l| l !~ /require/ && l !~ /^#/ }
  content[insert...insert] = ["", "SingleCov.covered!"]
  File.write(f, content.join("\n"))

  # run the test to check coverage
  result = `#{command.sub('%{file}', f)} 2>&1`
  if $?.success?
    puts "#{f} is good!"
    next
  end

  if uncovered = result[/\((\d+) current/, 1]
    # configure uncovered
    puts "Uncovered for #{f} is #{uncovered}"
    content[insert+1] = "SingleCov.covered! uncovered: #{uncovered}"
    File.write(f, content.join("\n"))
  else
    # mark bad tests for manual cleanup
    content[insert+1] = "# SingleCov.covered! # TODO: manually fix this"
    File.write(f, content.join("\n"))
    puts "Manually fix: #{f} ... output is:\n#{result}"
  end
end

Generating a coverage report

SingleCov.coverage_report = "coverage/.resultset.json"
SingleCov.coverage_report_lines = true # only report line coverage for coverage systems that do not support branch coverage

Author

Michael Grosser
[email protected]
License: MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].