Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 2.4.0
-
Fix Version/s: 2.5.0
-
Component/s: Documentation
-
Labels:None
-
Number of attachments :
Description
The cookbook example for testing a method must be called with an argument that is an ActionEvent only works if the method "doSomething" has a signature of void doSomething(Object).
This is due to the the Hamcrest matcher "instanceOf" being typed to Object rather than T.
This is the example in question:
one (mock).doSomething(with(instanceOf(ActionEvent.class)));
We've discussed this on the jMock mailing list. Thanks to Java's "special" implementation of generic types, the Java 5 and 6 compiler cannot compile code that uses instanceOf if instanceOf is defined with the appropriate generic constraints.
I'll have to remove it from the documentation and deprecate the function until the Java language definition is fixed.
--Nat