Skip to content

Commit

Permalink
Fixes mockito#2921 : work around Java type erasure
Browse files Browse the repository at this point in the history
  • Loading branch information
Jörg von Frantzius committed Feb 22, 2023
1 parent b27238a commit c6acab8
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ public static class UnderTest {
private UnderTest underTest;

/**
* Verify that InjectMocks will correctly match fields with same generic type but different type parameters, without using the same field name.
* Verify that InjectMocks will correctly match fields with same generic type but different type parameters,
* without using the same field name.
*/
@Test
public void testInjectMock() {
// this used to fail without any error message hinting at the problem, as soon as a class under test has
// a second field of the same generic type, but with different type parameter. The programmer then
// had to know that mock field names have to match field names in the class under test.
assertNotNull(underTest.stringListProvider);
assertNotNull(underTest.intListProvider);
}
Expand Down

0 comments on commit c6acab8

Please sign in to comment.