Skip to content

Flaky coverage, if use load #1132

@Yegorov

Description

@Yegorov

Hello!
I have such a problem:
If used load ... for load code, I only get coverage for the last test.

Example test case:

class TestApp < Minitest::Test
  def test_a_1
    assert_output('10') do
      $a = 1
      load(File.join(__dir__, "../app/main.rb"))
    end
  end

  def test_a_2
    assert_output('5') do
      $a = 2
      load(File.join(__dir__, "../app/main.rb"))
    end
  end

  def test_a_else
    assert_output('0') do
      $a = 3
      load(File.join(__dir__, "../app/main.rb"))
    end
  end
end

To make it clearer, I have sketched out a simple application: https://github.com/Yegorov/simplecov_flaky_coverage_if_use_load

Is it possible to somehow set it up so that the maximum coverage amount is used?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions