Skip to content

Simplecov evaluating the same file twice? #501

Closed

Description

@Spitigala

I've been at this for several days now with no luck.

I am attempting to add code coverage to my rails application, and want to do get overall coverage numbers for my Unit, functional and selenium tests. I am using minitest and jruby 1.7.19 (if that matters), and starting Simplecov in an initializer file so that I can get coverage numbers from my tomcat server process for selenium tests.

I've tried a number of configurations based on a recommendations I've read in various posts, and nothing has yielded expected results so far. My current set up looks like this:

# config/initializers/000_simplecov.rb
if ENV[ 'COVERAGE' ]
    require 'simplecov'
    require 'simplecov-teamcity-summary'

    SimpleCov.start 'rails' do

        SimpleCov.merge_timeout 5600

        at_exit do
            SimpleCov.result.format!
            SimpleCov::Formatter::TeamcitySummaryFormatter.new.format SimpleCov.result if ENV[ 'TEAMCITY_VERSION' ]
        end
    end
end

And I've also made use of the command_name method to distinguish various test suites, which I've placed at the very top of 1 of the test files in each of the suites, as recommended by the Simplecov documentation:

# test/functional/some_functional_test.rb
SimpleCov.command_name 'test:functionals'
# test/unit/some_unit_test.rb
SimpleCov.command_name 'test:units'
# test/selenium/some_selenium_test.rb
SimpleCov.command_name 'test:selenium'

I seem to be getting coverage reporting for my Unit and functional tests. Models and controllers are reporting what seem to be believable numbers. However, for some of my selenium tests, In the report I am noticing that the same lib file is evaluated twice, but one has 0% coverage and the other has some percentage of coverage. This is throwing off the overall coverage numbers.

The 2 identical files in the report look like this:

lib/qa/psd_components/tools.rb #reporting 0% coverage
lib//qa/psd_components/tools.rb # reporting 98% coverage

notice the extra forward slash after lib in the second, which seems to be causing simplecov to treat it as a different file. I am not sure why this is happening. Maybe my current set up isn't correct. Any help would be much appreciated.

Activity

  1. PragTob commented on Jan 25, 2017

    @PragTob
    Collaborator

    I'd put my money on this being a result of incorrect coverage data generated by JRuby 1.7.x which is fixed in JRuby 9.1. I know, it might be hard to ask you to upgrade your JRuby installation but I think that's most of what can be done here.

    If you disagree/the issue persists/whatever please feel free to reopen!

  2. added theissue type on May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions