Add tests for Sets utility class#3771
Conversation
Add comprehensive test coverage for Sets utility class which provides factory methods for creating mock-safe hash sets and regular sets. Tests cover all three static methods with various scenarios including mock objects, regular objects, edge cases, and error handling. - Test newMockSafeHashSet(Iterable<Object>) with various scenarios - Test newMockSafeHashSet(Object...) with various scenarios - Test newSet(T...) with various types - Test edge cases (empty collections, null handling, duplicates) - Test set operations (add, remove) - Fix AssertJ null handling by using explicit type casting to avoid NullPointerException
TimvdLippe
left a comment
There was a problem hiding this comment.
Thanks for these! They make sense to me. Only nit is about the comments.
|
|
||
| Set<Object> result = Sets.newMockSafeHashSet(mock, mock); | ||
|
|
||
| // Mock 객체는 동일한 인스턴스이므로 Set에는 하나만 포함 |
There was a problem hiding this comment.
Please either remove these comments or use English
There was a problem hiding this comment.
@TimvdLippe Thank you for the feedback! I've addressed your comment by translating all Korean comments to English and added class-level Javadoc for better documentation. The changes have been committed.
All comments are now in English:
- Translated 3 Korean comments to English
- Added class-level Javadoc for SetsTest
- Added 2 explanatory comments for AssertJ null handling
Please let me know if there's anything else that needs to be adjusted.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3771 +/- ##
============================================
+ Coverage 86.46% 86.48% +0.02%
- Complexity 2988 2989 +1
============================================
Files 341 341
Lines 9041 9041
Branches 1113 1113
============================================
+ Hits 7817 7819 +2
+ Misses 942 941 -1
+ Partials 282 281 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Replace Korean comments with English and add missing documentation to improve code readability and maintainability. - Add class-level Javadoc for SetsTest - Translate Korean comments to English (3 comments) - Add explanatory comments for AssertJ null handling (2 comments) - Improve code documentation consistency
Summary
Add comprehensive test coverage for
Setsutility class which provides factory methods for creating mock-safe hash sets and regular sets. This improves code coverage and ensures correct behavior of set creation methods.Changes
SetsTestclass with 17 test methods covering all three static methods:newMockSafeHashSet(Iterable<Object>)- 4 testsnewMockSafeHashSet(Object...)- 3 testsnewSet(T...)- 10 testsNote: AssertJ's
contains()andcontainsExactly()methods require explicit type casting when checking for null values (e.g.,contains((Object) null)) to avoidNullPointerExceptioncaused by varargs array creation.Testing
All tests pass:
./gradlew :mockito-core:test --tests "org.mockito.internal.util.collections.SetsTest"