Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class TubeClass {
public static boolean methodCalled = false;
public static boolean constructorCalled = false;
public TubeClass() {
constructorCalled = true;
System.err.println("I really wish you wouldn't call me.");
}
public void dontCallMe() {
methodCalled = true;
System.err.println("You won't call me.");
}
}
import groovy.util.GroovyTestCase
import static org.easymock.EasyMock.expect
import static org.easymock.classextension.EasyMock.createMock
import static org.easymock.classextension.EasyMock.replay
import static org.easymock.classextension.EasyMock.verify
class TubeClassTest extends GroovyTestCase {
void testShouldNotCallMethod() {
def mockObject = createMock(TubeClass)
expect(mockObject.dontCallMe()).atLeastOnce()
replay(mockObject)
mockObject.dontCallMe()
assert TubeClass.methodCalled == false
assert TubeClass.constructorCalled == false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment