-
Notifications
You must be signed in to change notification settings - Fork 39
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
Align TestMode import across test classes #630
Conversation
Looks good. No mutations were possible for these changes. |
Heyy @philleonard , thanks for opening the PR! 🚀 First some context related to this specific issue and the question about generalization:
Nice thoughts, and yes you are right, it is not easy to generalize this and auto-detect candidates for static importing. For that reason we have a curated set of candidates for statically importing things. We have the rule that we should not "lose" any context if we statically import something. This usually holds for imports that have I have to go now so will get back to your question about the test abstraction later 😄. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally we try to combine PRs such as this one with a check that enforces the change, but as @rickie says we already have #450 for this. I'm fine with merging this PR as-is :)
I tweaked the suggested commit message :)
This leads onto another question: should we not provide some form of test abstraction (harness) for
BugChecker
tests? Might also be nice to look at a cleaner test data setup, or perhaps there is a reason to providing varargs String's inCompilationTestHelper#addSourceLines
over reading from a.java
source file?
Error Prone does support moving the test code to separate resource files, but in practice this makes test maintenance harder, and as such we see that new upstream Error Prone tests also prefer the current approach.
That said... yes, we can do better 😄. See #198, where we'll move to text blocks. That in turn unlocks IntelliJ IDEA language injection support :)
Nice! Having played around with #198 this is already a much nicer experience for writing these test classes (which I have been doing in a scratch file for now). Copilot suggestions and IntelliJ autocomplete also "work" within language injections so that is nice. After a quick scan, GitHub and the IntelliLang both have somewhat "incomplete" syntax highlighting, but already much better than what we currently have. |
1ac7cca
to
9ac789f
Compare
Looks good. No mutations were possible for these changes. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Small cleanup to align with other test classes in this package.
🧹 Whilst an ad-hoc cleanup when working on something else, I'm not sure it can be generalised (and likely one you have already considered so I'm interested to know your opinions!).
What factors come into play when deciding between an import and a static import for accessing static members of a class? Ones I consider that cannot be generalised (trivially):
#replacement
tests and therefore you could argue we could drop the qualifier. This leads onto another question: should we not provide some form of test abstraction (harness) forBugChecker
tests? Might also be nice to look at a cleaner test data setup, or perhaps there is a reason to providing varargs String's inCompilationTestHelper#addSourceLines
over reading from a.java
source file?Suggested commit message (not much to say about this change so probably too verbose/redundant):