Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Minitest/NonExecutableTestMethod cop #50379

Conversation

yahonda
Copy link
Member

@yahonda yahonda commented Dec 17, 2023

Motivation / Background

This pull request enables Minitest/NonExecutableTestMethod cop to find non-executed test that is out of ActiveSupport::TestCase and its subclasses.

This cop is based on the request since there was a test that is not executed found at #50334 (comment) and implemented to RuboCop Minitest 0.34.0 via rubocop/rubocop-minitest#279

Detail

This cop works as follows.
As of right now, there is no offenses by reverting the merge commit via #50334

$ git revert -m 1 9517841
$ bundle exec rubocop
Inspecting 3254 files
... snip ...

Offenses:

activerecord/test/cases/assertions/query_assertions_test.rb:27:5: W: Minitest/NonExecutableTestMethod: Test method should be defined inside a test class to ensure execution.
    def test_assert_no_queries ...
    ^^^^^^^^^^^^^^^^^^^^^^^^^^

3254 files inspected, 1 offense detected
$

Additional information

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

@yahonda
Copy link
Member Author

yahonda commented Dec 17, 2023

Let me take a look at two offenses detected at https://github.com/rails/rails/actions/runs/7237053923/job/19716256259?pr=50379

@koic
Copy link
Contributor

koic commented Jan 3, 2024

JFYI, #50515 has been merged.

This pull request enables `Minitest/NonExecutableTestMethod` cop
to find non-executed test that is out of `ActiveSupport::TestCase` and its subclasses.

This cop is based on the request since there was a test that is not executed found
at rails#50334 (comment)
and implemented to RuboCop Minitest 0.34.0 via rubocop/rubocop-minitest#279

This cop works as follows.
As of right now, there is no offenses by reverting the merge commit via rails#50334

```
$ git revert -m 1 9517841
$ bundle exec rubocop
Inspecting 3254 files
... snip ...

Offenses:

activerecord/test/cases/assertions/query_assertions_test.rb:27:5: W: Minitest/NonExecutableTestMethod: Test method should be defined inside a test class to ensure execution.
    def test_assert_no_queries ...
    ^^^^^^^^^^^^^^^^^^^^^^^^^^

3254 files inspected, 1 offense detected
$
```

* `Gemfile.lock` has been updated as follows
```
bundle update rubocop rubocop-minitest --conservative
```
@rafaelfranca rafaelfranca force-pushed the enable_minitest_non_executable_test_method_cop branch from dbd4669 to 6384eec Compare January 3, 2024 17:04
@rafaelfranca rafaelfranca merged commit 16388f6 into rails:main Jan 3, 2024
4 checks passed
@yahonda yahonda deleted the enable_minitest_non_executable_test_method_cop branch April 19, 2024 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants