rubocop / rubocop-minitest

Code style checking for Minitest files.
https://docs.rubocop.org/rubocop-minitest
MIT License
144 stars 44 forks source link

[Fix #279] Add new `Minitest/NonExecutableTestMethod` cop #280

Closed koic closed 11 months ago

koic commented 11 months ago

Resolves #279.

This PR adds new Minitest/NonExecutableTestMethod cop, which checks for the use of test methods outside of a test class. Test methods should be defined within a test class to ensure their execution.

NOTE: This cop assumes that classes whose superclass name includes the word "Test" are test classes, in order to prevent false positives.

# bad
class FooTest < Minitest::Test
end
def test_method_should_be_inside_test_class
end

# good
class FooTest < Minitest::Test
  def test_method_should_be_inside_test_class
  end
end

Before submitting the PR make sure the following are checked:

yahonda commented 11 months ago

Thanks for implementing the Minitest/NonExecutableTestMethod cop. I have opened https://github.com/rails/rails/pull/50379 to enable this cop at Rails.