-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Added new duplicated_test_run cop #164
Merged
koic
merged 1 commit into
rubocop:master
from
ignacio-chiazzo:ignacio-chiazzo/add-duplicated-test-run-cop
Mar 31, 2022
Merged
Added new duplicated_test_run cop #164
koic
merged 1 commit into
rubocop:master
from
ignacio-chiazzo:ignacio-chiazzo/add-duplicated-test-run-cop
Mar 31, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ignacio-chiazzo
changed the title
Remove having multiple CHANGELOG files from the CONTRIBUTING README
Added new duplicated_test_run cop
Mar 26, 2022
ignacio-chiazzo
force-pushed
the
ignacio-chiazzo/add-duplicated-test-run-cop
branch
2 times, most recently
from
March 26, 2022 22:34
1e385a4
to
13d7a9e
Compare
koic
reviewed
Mar 29, 2022
koic
reviewed
Mar 29, 2022
koic
reviewed
Mar 29, 2022
koic
reviewed
Mar 29, 2022
andyw8
reviewed
Mar 29, 2022
ignacio-chiazzo
force-pushed
the
ignacio-chiazzo/add-duplicated-test-run-cop
branch
from
March 29, 2022 23:09
13d7a9e
to
df5ec71
Compare
Nice! Can you squash your commits into one? |
ignacio-chiazzo
force-pushed
the
ignacio-chiazzo/add-duplicated-test-run-cop
branch
2 times, most recently
from
March 30, 2022 17:13
a621b20
to
84a390e
Compare
If a Minitest class inherits from another class, it will also inherit its methods causing Minitest to run the parent’s tests methods twice. This PR detects when there are two tests classes, one inherits from the other, and both have tests methods. MinitestRubocop will add an offence to the Child class in such a case. Note that this cop only works if both classes are on the same file.
ignacio-chiazzo
force-pushed
the
ignacio-chiazzo/add-duplicated-test-run-cop
branch
from
March 30, 2022 17:14
84a390e
to
98ebb10
Compare
Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added new duplicated_test_run cop
If a Minitest class inherits from another class, it will also inherit its methods causing Minitest to run the parent's tests methods twice.
This PR detects when there are two tests classes, one inherits from the other, and both have tests methods. MinitestRubocop will add an offence to the Child class in such a case.
For example:
It will run
test_1
twice!I came across a few PRs/pieces of code using subclassing. I wrote a Gem that detects duplicated test run during Runtime and a Post with more details.
This cop has some limitations:
describes
also has the same problem, and the cop doesn't detect it (yet ;)).More information in this post.