-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
test: Use Assume.assumeThat for SequencedCollection tests #3711
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
base: main
Are you sure you want to change the base?
test: Use Assume.assumeThat for SequencedCollection tests #3711
Conversation
…ard `Assume.assumeThat` utility for conditional execution. Follow-up to mockito#3708 Signed-off-by: BeomSeogKim <kbs4520@daum.net>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3711 +/- ##
============================================
- Coverage 86.43% 86.42% -0.02%
Complexity 2969 2969
============================================
Files 341 341
Lines 9011 9011
Branches 1110 1110
============================================
- Hits 7789 7788 -1
- Misses 941 942 +1
Partials 281 281 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
@bric3 can you review as well? I think my review is what you intended, but I want to make sure I capture your intent as well.
Object result = values.returnValueFor(sequencedSetClass); | ||
assertNotNull("SequencedSet should return non-null value", result); | ||
assertTrue("Should return empty set", ((Set<?>) result).isEmpty()); | ||
assertTrue("Should return LinkedHashSet instance", result instanceof LinkedHashSet); | ||
} | ||
|
||
@Test | ||
public void should_return_empty_sequenced_map_on_java21() throws Exception { | ||
Class<?> sequencedMapClass = getClassOrSkipTest("java.util.SequencedMap"); |
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.
Can we use the same approach for all other usages of getClassOrSkipTest
? E.g. so that we can completely remove that method.
sequencedCollectionClass = null; | ||
} | ||
|
||
assumeThat( |
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.
Can we move the assumption before looking up the class and instead check it with the Java version? So the assumption checks that the Java version is at least 21 and then we do the class lookup. If we can't find the class, we throw an error to fail the test (you can add throws to the test method)
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.
@TimvdLippe Thanks for the feedback. I've pushed the requested changes. Please take another look.
Signed-off-by: BeomSeogKim <kbs4520@daum.net>
This is a follow-up to the discussion in PR #3708
Description
As suggested by @TimvdLippe in the original PR, this change refactors the test for JDK 21's
SequencedCollection
to use the project's standardAssume.assumeThat
utility for conditional execution.The previous implementation used a custom helper method
getClassOrSkipTest
to check for the presence of the class.This PR replaces that logic with an explicit check for the Java version, ensuring the test only runs on JDK 21 or newer.
Key Changes
getClassOrSkipTest
call with anAssume.assumeThat
check on the Java version.Checklist
including project members to get a better picture of the change
commit is meaningful and help the people that will explore a change in 2 years
./gradlew spotlessApply
for auto-formatting)Fixes #<issue number>
in the description if relevantFixes #<issue number>
if relevant