Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

BeomSeogKim
Copy link
Contributor

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 standard Assume.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

  • Replaced the getClassOrSkipTest call with an Assume.assumeThat check on the Java version.

Checklist

  • Read the contributing guide
  • PR should be motivated, i.e. what does it fix, why, and if relevant how
  • If possible / relevant include an example in the description, that could help all readers
    including project members to get a better picture of the change
  • Avoid other runtime dependencies
  • Meaningful commit history ; intention is important please rebase your commit history so that each
    commit is meaningful and help the people that will explore a change in 2 years
  • The pull request follows coding style (run ./gradlew spotlessApply for auto-formatting)
  • Mention Fixes #<issue number> in the description if relevant
  • At least one commit should end with Fixes #<issue number> if relevant

…ard `Assume.assumeThat` utility for conditional execution.

Follow-up to mockito#3708

Signed-off-by: BeomSeogKim <kbs4520@daum.net>
@codecov-commenter
Copy link

codecov-commenter commented Aug 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.42%. Comparing base (144751b) to head (8dd9daf).
⚠️ Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@TimvdLippe TimvdLippe left a 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");
Copy link
Contributor

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(
Copy link
Contributor

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)

Copy link
Contributor Author

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants