I cannot say why your code above does not work, but there are several ways in Groovy to make fun of Java classes without using MockFor . For example, if you want to intercept all calls for an object, you can implement invokeMethod in a class metaclass, for example.
class SomeJavaClass {
Alternatively, if you just want to provide an object that supports SomeJavaClass method SomeJavaClass , you can use either Map or Expando with properties where:
- property name names correspond to method names
- proprerty values โโare locks that take the same parameters as methods
If you can provide a little more information about how the layout is used, maybe I can offer some more specific suggestions.
source share