-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix minimum_coverage_by_file check & prep 0.21.1 (#966)
minimum_coverage_by_file was a gaping hole in the test suite, which is now partially remedied through rather thorough cucumber scenarios and 2 small unit tests that should be expanded on in the future. On the negative side: This will inconvenince some people. On the positive side stuffed another hole in the test suite towards a better future :D Also it was reported very soon thanks to @iMacTia Fixes #965
- Loading branch information
Showing
8 changed files
with
121 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
@test_unit @config | ||
Feature: | ||
|
||
Exit code should be non-zero if the coverage of any one file is below the configured value. | ||
|
||
Background: | ||
Given I'm working on the project "faked_project" | ||
|
||
Scenario: slightly under minimum coverage by file | ||
Given SimpleCov for Test/Unit is configured with: | ||
""" | ||
require 'simplecov' | ||
SimpleCov.start do | ||
add_filter 'test.rb' | ||
minimum_coverage_by_file 75.01 | ||
end | ||
""" | ||
|
||
When I run `bundle exec rake test` | ||
Then the exit status should not be 0 | ||
And the output should contain "Line coverage by file (75.00%) is below the expected minimum coverage (75.01%)." | ||
And the output should contain "SimpleCov failed with exit 2" | ||
|
||
Scenario: Just passing it | ||
Given SimpleCov for Test/Unit is configured with: | ||
""" | ||
require 'simplecov' | ||
SimpleCov.start do | ||
add_filter 'test.rb' | ||
minimum_coverage_by_file 75 | ||
end | ||
""" | ||
|
||
When I run `bundle exec rake test` | ||
Then the exit status should be 0 | ||
|
||
@branch_coverage | ||
Scenario: Works together with branch coverage and the new criterion announcing both failures | ||
Given SimpleCov for Test/Unit is configured with: | ||
""" | ||
require 'simplecov' | ||
SimpleCov.start do | ||
add_filter 'test.rb' | ||
enable_coverage :branch | ||
minimum_coverage_by_file line: 90, branch: 70 | ||
end | ||
""" | ||
|
||
When I run `bundle exec rake test` | ||
Then the exit status should not be 0 | ||
And the output should contain "Line coverage by file (80.00%) is below the expected minimum coverage (90.00%)." | ||
And the output should contain "Branch coverage by file (50.00%) is below the expected minimum coverage (70.00%)." | ||
And the output should contain "SimpleCov failed with exit 2" | ||
|
||
@branch_coverage | ||
Scenario: Can set branch as primary coverage and it will fail if branch is below minimum coverage | ||
Given SimpleCov for Test/Unit is configured with: | ||
""" | ||
require 'simplecov' | ||
SimpleCov.start do | ||
add_filter 'test.rb' | ||
enable_coverage :branch | ||
primary_coverage :branch | ||
minimum_coverage_by_file 70 | ||
end | ||
""" | ||
|
||
When I run `bundle exec rake test` | ||
Then the exit status should not be 0 | ||
And the output should contain "Branch coverage by file (50.00%) is below the expected minimum coverage (70.00%)." | ||
And the output should not contain "Line coverage" | ||
And the output should contain "SimpleCov failed with exit 2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module SimpleCov | ||
VERSION = "0.21.0" | ||
VERSION = "0.21.1" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
require "helper" | ||
|
||
RSpec.describe SimpleCov::ExitCodes::MinimumCoverageByFileCheck do | ||
let(:result) do | ||
instance_double(SimpleCov::Result, coverage_statistics_by_file: stats) | ||
end | ||
let(:stats) do | ||
{ | ||
line: [SimpleCov::CoverageStatistics.new(covered: 8, missed: 2)] | ||
} | ||
end | ||
|
||
subject { described_class.new(result, minimum_coverage_by_file) } | ||
|
||
context "all files passing requirements" do | ||
let(:minimum_coverage_by_file) { {line: 80} } | ||
|
||
it "passes" do | ||
expect(subject).not_to be_failing | ||
end | ||
end | ||
|
||
context "one file violating requirements" do | ||
let(:minimum_coverage_by_file) { {line: 90} } | ||
|
||
it "fails" do | ||
p minimum_coverage_by_file | ||
expect(subject).to be_failing | ||
end | ||
end | ||
end |