-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Improve enforcer rule error messages #343
base: master
Are you sure you want to change the base?
Conversation
elharo
commented
Jan 9, 2025
•
edited
Loading
edited
- Avoid abbreviations
- Increase test coverage
- Make messages platform independent
- Don't double print paths to files
- Verify test setup with assumptions rather than asserts
buf.append(message + System.lineSeparator()); | ||
buf.append(message + '\n'); |
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.
I'm not sure how it will be worked on windows console ....
Can anybody confirm ...
@michael-o @Bukama
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.
Agree, this isn't right
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.
Note that this method does not print anything on the console. It throws an exception object that should be identical regardless of the platform that creates it. Where this message goes is outside the scope of this class. It might be written to a log file and never show up on a console. It might be suppressed completely.
In 2025 Windows shells behave in the obvious way if you send them a linefeed, so this works just fine across platforms if someone does happen to print this string to a console. Maybe System.lineSeparator was needed in Windows 95. It isn't now.
buf.append(message + System.lineSeparator()); | ||
buf.append(message + '\n'); |
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.
Agree, this isn't right
Build (
|
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
import static org.junit.jupiter.api.Assertions.*; |
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.
Is the introduction of star imports on purpose? (here and in other test files)
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.
should was be catched by checkstyle ... 🤔
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.
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.
no, not intentional. Let me fix it.
@Bukama site is broken for all maven-plugins and Maven 4.x |
assertFalse(f.exists()); | ||
assumeFalse(f.exists()); |
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.
It will change test logic ... at all
When file will be not deleted .. test will be marked as skipped not failed
Is it intentional?
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.
Yes, we don't want to test that the JDK's delete method works as expected, and if the code under test isn't even executed then the test has been skipped, not failed. This case inspired me to write https://cafe.elharo.com/testing/assume-vs-assert/
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.
PTAL
Ping |