Version
JMockit: 1.33
JUnit: 4.11
Java: 1.8.0_66
Description
A mocked generic method will return an instance of the mocked class, instead of a mock matching the type of the parameter. This can be demonstrated with the code below, which produces the following error when run:
java.lang.ClassCastException: package.Class$TestClass cannot be cast to java.lang.String
Code to Reproduce
@Mocked private TestClass mockedTestClass = null;
@Test
public void test()
{
System.out.println(new TestClass().testMethod("test"));
}
private static class TestClass
{
public <R> R testMethod(R value)
{
return value;
}
}