File: minimum_coverage_by_file.feature

package info (click to toggle)
ruby-simplecov 0.22.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,500 kB
  • sloc: ruby: 5,550; makefile: 10
file content (72 lines) | stat: -rw-r--r-- 2,463 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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"