Repository navigation
Feature 2921 generic types - #2923
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2923 +/- ##
============================================
- Coverage 85.65% 84.60% -1.06%
- Complexity 2847 2850 +3
============================================
Files 325 325
Lines 8623 8682 +59
Branches 1060 1071 +11
============================================
- Hits 7386 7345 -41
- Misses 964 1056 +92
- Partials 273 281 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| WildcardType wildcardTypeToMock = (WildcardType) typeToMock; | ||
| Type[] upperBounds = wildcardTypeToMock.getUpperBounds(); | ||
| return Arrays.stream(upperBounds).anyMatch(t -> isCompatibleTypes(t, mockType)); | ||
| } else if (typeToMock instanceof GenericArrayType && mockType instanceof GenericArrayType) { |
There was a problem hiding this comment.
CodeCov reports this branch is not covered. Can you please expand the coverage here or remove this check?
There was a problem hiding this comment.
Removed not covered code
There was a problem hiding this comment.
There is still some coverage missing, can you either remove the uncovered branches or add regression tests that cover the logic? https://app.codecov.io/gh/mockito/mockito/pull/2923/blob/src/main/java/org/mockito/internal/configuration/injection/filter/TypeBasedCandidateFilter.java Since this is intricate logic and a hot codepath, I would like to see full coverage here.
|
@TimvdLippe please review and resolve where appropriate |
|
https://github.com/mockito/mockito/actions/runs/4296719412/jobs/7488794171 I don't know what to make of this, maybe just re-run? |
|
@TimvdLippe thx for restarting the build. Did you have a chance to take a look at my comments on your review? Sorry for maybe being pushy, but I have some time on my hands for this at the moment, which might change soon. Also I don't know under what circumstances you are able to devote time to Mockito :) |
|
I am on vacation this week, but should be back next week to review. |
|
Alright, have a nice vacation! |
|
@jfrantzius Apart from the missing code coverage, this PR LGTM! |
|
@TimvdLippe I added more test coverage |
|
@jfrantzius please look at the code coverage report and see which branches are missing coverage. There are still some missing, for example one where the generic types don't match. |
|
I added support for generic injectee classes, e.g. public class UnderTestWithTypeParameters<T1, T2> {
List<T1> t1List;
Set<T2> t2Set;
}There is one line that cannot be covered in tests, please see the comment there: https://github.com/jfrantzius/mockito/blob/feature-2921-generic-type/src/main/java/org/mockito/internal/configuration/injection/filter/TypeBasedCandidateFilter.java#L70 |
|
Could you please approve the workflow @TimvdLippe ? |
|
@TimvdLippe I'm off for today, if you trigger the build then the last line missing in coverage should now be covered as well. |
|
I guess it's time to setup Spotless in my IDE ... |
|
I would love to be able to start builds, but unfortunately I have to always bug you about it @TimvdLippe :) |
|
@TimvdLippe build might need another nudge in https://github.com/mockito/mockito/actions/runs/4372977101/jobs/7658608894 |
|
WDYT @TimvdLippe , is it good to merge? |
TimvdLippe
left a comment
There was a problem hiding this comment.
Thanks for all the work, this LGTM!

Fixes #2921 by preserving and using the generic Java type information that was previously lost to type erasure.
Contains a JUnit test with usage example, demonstrating that fields with generic types do not need to have matching names anymore.