|
| 1 | +@test_unit @config |
| 2 | +Feature: |
| 3 | + |
| 4 | + Exit code should be non-zero if the coverage of any one file is below the configured value. |
| 5 | + |
| 6 | + Background: |
| 7 | + Given I'm working on the project "faked_project" |
| 8 | + |
| 9 | + Scenario: slightly under minimum coverage by file |
| 10 | + Given SimpleCov for Test/Unit is configured with: |
| 11 | + """ |
| 12 | + require 'simplecov' |
| 13 | + SimpleCov.start do |
| 14 | + add_filter 'test.rb' |
| 15 | + minimum_coverage_by_file 75.01 |
| 16 | + end |
| 17 | + """ |
| 18 | + |
| 19 | + When I run `bundle exec rake test` |
| 20 | + Then the exit status should not be 0 |
| 21 | + And the output should contain "Line coverage by file (75.00%) is below the expected minimum coverage (75.01%)." |
| 22 | + And the output should contain "SimpleCov failed with exit 2" |
| 23 | + |
| 24 | + Scenario: Just passing it |
| 25 | + Given SimpleCov for Test/Unit is configured with: |
| 26 | + """ |
| 27 | + require 'simplecov' |
| 28 | + SimpleCov.start do |
| 29 | + add_filter 'test.rb' |
| 30 | + minimum_coverage_by_file 75 |
| 31 | + end |
| 32 | + """ |
| 33 | + |
| 34 | + When I run `bundle exec rake test` |
| 35 | + Then the exit status should be 0 |
| 36 | + |
| 37 | + @branch_coverage |
| 38 | + Scenario: Works together with branch coverage and the new criterion announcing both failures |
| 39 | + Given SimpleCov for Test/Unit is configured with: |
| 40 | + """ |
| 41 | + require 'simplecov' |
| 42 | + SimpleCov.start do |
| 43 | + add_filter 'test.rb' |
| 44 | + enable_coverage :branch |
| 45 | + minimum_coverage_by_file line: 90, branch: 70 |
| 46 | + end |
| 47 | + """ |
| 48 | + |
| 49 | + When I run `bundle exec rake test` |
| 50 | + Then the exit status should not be 0 |
| 51 | + And the output should contain "Line coverage by file (80.00%) is below the expected minimum coverage (90.00%)." |
| 52 | + And the output should contain "Branch coverage by file (50.00%) is below the expected minimum coverage (70.00%)." |
| 53 | + And the output should contain "SimpleCov failed with exit 2" |
| 54 | + |
| 55 | + @branch_coverage |
| 56 | + Scenario: Can set branch as primary coverage and it will fail if branch is below minimum coverage |
| 57 | + Given SimpleCov for Test/Unit is configured with: |
| 58 | + """ |
| 59 | + require 'simplecov' |
| 60 | + SimpleCov.start do |
| 61 | + add_filter 'test.rb' |
| 62 | + enable_coverage :branch |
| 63 | + primary_coverage :branch |
| 64 | + minimum_coverage_by_file 70 |
| 65 | + end |
| 66 | + """ |
| 67 | + |
| 68 | + When I run `bundle exec rake test` |
| 69 | + Then the exit status should not be 0 |
| 70 | + And the output should contain "Branch coverage by file (50.00%) is below the expected minimum coverage (70.00%)." |
| 71 | + And the output should not contain "Line coverage" |
| 72 | + And the output should contain "SimpleCov failed with exit 2" |
0 commit comments