-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
HADOOP-19425. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-azure Part1. #7369
base: trunk
Are you sure you want to change the base?
Conversation
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
7f6734c
to
b52214a
Compare
I am trying to modify the code of hadoop-azure, this is part 1. I am syncing the improvements so that it can be better reviewed: 1. TestNameIn JUnit 5, the Here is an example:
2. TimeoutIn JUnit 5, Here is an example:
3. Assume.assumeNotNull → Assumptions.assumeTrueIn JUnit 5, there is no Here is an example:
4. ExpectedException → assertThrowsIn JUnit 5, the 5. @ignore → @disabledIn JUnit 5, 6. Method Order: @FixMethodOrder → @TestMethodOrderIn JUnit 5, |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@cnauroth @steveloughran @anujmodi2021 Can you help review this PR? Thank you very much! |
🎊 +1 overall
This message was automatically generated. |
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.
Hi @slfan1989 . This looks good to me overall. I entered one question.
Are you able to run these tests against Azure to make sure they're all working? Unfortunately, I can't help with that kind of testing. I can test GCS and S3A (using GCS's S3-compatible XML API), but not the other cloud providers. If you need help with this testing, then you might need to work with someone else.
@@ -434,10 +431,6 @@ class MatchesPattern extends TypeSafeMatcher<String> { | |||
} | |||
} | |||
|
|||
expectedEx.expectMessage(new MatchesPattern( |
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.
Did we lose an expectation here?
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.
In JUnit 5, org.junit.rules.ExpectedException
has been deprecated, and it is recommended to use assertThrows to validate exception throwing, as shown below:
import static org.junit.jupiter.api.Assertions.assertThrows;
@Test
public void shouldThrowException() {
assertThrows(IllegalArgumentException.class, () -> {
someMethodThatThrows();
});
}
The change is primarily in syntax, where assertThrows captures exceptions via lambda expressions, replacing the ExpectedException rule from JUnit 4. However, it does not have any fundamental impact on the logic of unit tests.
I can further improve this unit test to also validate the exception message using a regular expression.
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 have seen the conversions to assertThrows
. Those all look good.
Perhaps what I find confusing is that the setupExpectations()
method now seems to be a no-op. It seems to define a custom matcher class, but then never use it. Should setupExpectations()
be removed, or am I missing something?
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 your suggestion! I also believe that setupExpectations
should be removed. I will continue to improve the code.
@cnauroth Thank you very much for your explanation! I think this change needs to be verified by @steveloughran and @anujmodi2021 together, and I hope it can pass the integration tests. If there are any issues, I will make improvements as needed. |
🎊 +1 overall
This message was automatically generated. |
Description of PR
JIRA: HADOOP-19425. Upgrade JUnit from 4 to 5 in hadoop-azure Part1.
How was this patch tested?
Junit Test.
For code changes:
LICENSE
,LICENSE-binary
,NOTICE-binary
files?