In my attempt to mock an object in Groovy using a package mock.interceptor:
def mock = new MockFor(TheClass);
mock.demand.theMethod{ "return" }
mock.use {
def underTest = new TheClass()
println underTest.theMethod()
}
The problem is creating TheClass()in the block use{, it uses the actual constructor, which in this case I would prefer not to use it. How do I instantiate this class so that I can test the method I care about theMethodwithout using a constructor?
Using EasyMock / CE, mocks can be done without using a constructor, but curious how to achieve this in Groovy.
Popsicle polly
source
share