Skip to content

Commit

Permalink
fix: make minitest sampling work
Browse files Browse the repository at this point in the history
Co-Authored-By: @ericenns
  • Loading branch information
palkan committed May 8, 2024
1 parent cdf4b82 commit d07ba0e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/test_prof/recipes/minitest/sample.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ module MinitestSample
CORE_RUNNABLES = [
Minitest::Test,
defined?(Minitest::Unit::TestCase) ? Minitest::Unit::TestCase : nil,
Minitest::Spec
defined?(Minitest::Spec) ? Minitest::Spec : nil,
].compact.freeze

class << self
def suites
# Make sure that sample contains only _real_ suites
Minitest::Runnable.runnables
.reject { |suite| CORE_RUNNABLES.include?(suite) }
.select do |suite|
CORE_RUNNABLES.any? { |kl| suite < kl } && suite.runnable_methods.any?
end
end

def sample_groups(sample_size)
Expand Down
5 changes: 4 additions & 1 deletion spec/integrations/fixtures/minitest/sample_fixture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ def test_pass2
end
end

class AnotherSomethingTest < Minitest::Test
class CustomTestCase < Minitest::Test
end

class AnotherSomethingTest < CustomTestCase
def test_pass
assert true
end
Expand Down

0 comments on commit d07ba0e

Please sign in to comment.