keeganwitt / gmock

Automatically exported from code.google.com/p/gmock
6 stars 2 forks source link

Using a non type variable to a type variable give bad error message #47

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Using a non type variable to a type variable like in:

Date date = mock()

Give:
java.lang.ClassCastException:
org.gmock.internal.recorder.ReturnMethodRecorder cannot be cast to
java.lang.String

Which make it really difficult to tell what is happening.

Original issue reported on code.google.com by julien.g...@gmail.com on 16 Jan 2009 at 8:13

GoogleCodeExporter commented 9 years ago
The only way to fix this bug is, not allowing recording expectation of the 
method
"toString()" in Java, that is, if the "toString()" method is called from the 
Java
side and it is in record state, invoke a default implementation (e.g. return 
"Mock
for SomeClass").

It is a rare case, so it is acceptable.

Original comment by JohnnyJianHY on 16 Jan 2009 at 12:03

GoogleCodeExporter commented 9 years ago

Original comment by JohnnyJianHY on 16 Jan 2009 at 12:26

GoogleCodeExporter commented 9 years ago

Original comment by JohnnyJianHY on 16 Jan 2009 at 12:32