Skip to content

Method coverage conflates methods with the same name #1217

Description

@G-Rath

I've been doing my periodic check-in w/ turbo_tests2 and simplecov v1 rcs - really loving the progress I'm seeing!

I have found an odd behaviour with method coverage not reporting some methods as covered when used with turbo_tests2, but they are with rspec - while I'm not sure in what gem that issue lies, in trying to reproduce it in my reproduction repository I believe I have found a bug in simplecov that might be the actual issue.

In a nutshell it seems that something in the method coverage code is mixing up methods with the same name i.e. G-Rath/simplecov-wat@cc71b05 adds methods add3 and substract3 in a new file (math/math3.rb) which are fully covered by spec/math/math3_spec.rb, while also adding a different version of add3 to math/add.rb which is not covered.

Running with turbo_tests2 reports both line and method coverage as below 100%:

Coverage report generated for rspec-1, rspec-2, rspec-3, rspec-4 to coverage/index.html
Line coverage: 25 / 26 (96.15%)
Branch coverage: 24 / 24 (100.00%)
Method coverage: 5 / 6 (83.33%)
Line coverage (96.15%) is below the expected minimum coverage (100.00%).
  Lowest-coverage files (line):
     87.50%  math/add.rb
    100.00%  math/divide.rb
    100.00%  math/math3.rb
    100.00%  math/subtract.rb
Method coverage (83.33%) is below the expected minimum coverage (100.00%).
  Lowest-coverage files (method):
     50.00%  math/add.rb
    100.00%  math/divide.rb
    100.00%  math/math3.rb
    100.00%  math/subtract.rb
SimpleCov failed with exit 2 due to a coverage related error

However, running with rspec reports only line coverage as below 100%, and that there are only 5 methods instead of 6:

Coverage report generated for RSpec to coverage/index.html
Line coverage: 25 / 26 (96.15%)
Branch coverage: 24 / 24 (100.00%)
Method coverage: 5 / 5 (100.00%)
Line coverage (96.15%) is below the expected minimum coverage (100.00%).
  Lowest-coverage files (line):
     87.50%  math/add.rb
    100.00%  math/divide.rb
    100.00%  math/math3.rb
    100.00%  math/subtract.rb
SimpleCov failed with exit 2 due to a coverage related error

Metadata

Metadata

Assignees

No one assigned

    Labels

    CoverageIssues related to the Coverage standard libraryHas Repro Repo

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions