-
-
Notifications
You must be signed in to change notification settings - Fork 77
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
Add JUnit test for Day007.class #181
Conversation
Co-authored-by: Helber Belmiro <helber.belmiro@gmail.com>
Co-authored-by: Helber Belmiro <helber.belmiro@gmail.com>
Co-authored-by: Helber Belmiro <helber.belmiro@gmail.com>
Co-authored-by: Helber Belmiro <helber.belmiro@gmail.com>
Hi @hbelmiro, I'm quoting you to see my pull request 😄 |
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.
Thank you for this contribution @Viniberaldo.
The idea is to replace the existing code with tests. So, you need to move the example to the test and remove the original class.
Also, since we'll use tests, we can change the example to not print the formatted message. In the original code, I've printed it to the console so people can see the result. Now that we'll have a test, the test itself is the verification. So all the boilerplate you had to add to verify the output can be removed.
See what I did here, for example: https://github.com/hbelmiro/100DaysOfJava/pull/62/files
days/day007/src/test/java/com/thegreatapi/ahundreddaysofjava/day007/Day007Test.java
Outdated
Show resolved
Hide resolved
days/day007/src/main/java/com/thegreatapi/ahundreddaysofjava/day007/Day007.java
Outdated
Show resolved
Hide resolved
f894dec
to
44031ad
Compare
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.
Thank you @Viniberaldo. Looks way better now.
I left a few more comments.
days/day007/src/main/java/com/thegreatapi/ahundreddaysofjava/day007/Day007.java
Show resolved
Hide resolved
days/day007/src/test/java/com/thegreatapi/ahundreddaysofjava/day007/Day007Test.java
Outdated
Show resolved
Hide resolved
days/day007/src/test/java/com/thegreatapi/ahundreddaysofjava/day007/Day007Test.java
Outdated
Show resolved
Hide resolved
… and removes the Day007 class and its directory. Key changes: Created Day007Test.java in src/test/java/com/thegreatapi/ahundreddaysofjava/day007 Removed the Day007 class and its directory Added a single test method "shouldFormatMessageCorrectly()" to test the showMessage() method Implemented the test using JUnit 5 and AssertJ for more readable assertions The test verifies that the showMessage() method correctly formats the message using MessageFormat. Benefits: Ensures proper formatting of the message Provides confidence in the correctness of the showMessage() method Please review the test implementation and provide feedback if needed.
… and removes the Day007 class and its directory. Key changes: Created Day007Test.java in src/test/java/com/thegreatapi/ahundreddaysofjava/day007 Removed the Day007 class and its directory Added a single test method "shouldFormatMessageCorrectly()" to test the showMessage() method Implemented the test using JUnit 5 and AssertJ for more readable assertions The test verifies that the showMessage() method correctly formats the message using MessageFormat. Benefits: Ensures proper formatting of the message Provides confidence in the correctness of the showMessage() method Please review the test implementation and provide feedback if needed.
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.
@Viniberaldo can you rebase?
This pull request introduces a new JUnit test class (Day007Test.java) to verify the functionality of the Day007 class.
Key changes:
The test verifies that the showMessage() method correctly formats the message using MessageFormat.
Benefits:
Please review the test implementation and provide feedback if needed.