This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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