26 Jun 2012 01:19
Re: ignoring except never for one method
I don think so. Perhaps an actual example with all the code might help
explain:
In this example I am mocking Piston and don't want engine to call the
piston's snap() method when it starts, but I don't care what other methods
on piston it calls. I could declare all the individual methods that
starting the engine calls on piston, but that makes the test fragile when I
change the engine implementation and add further calls to piston.
The test below passes, but I want it to fail because the engine is calling
snap on piston
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.junit.Test;
public class MockNever {
<at> Test
public void testMockNever() {
// setup
Mockery mockery = new Mockery();
final Engine engine = new Engine();
final Piston piston = mockery.mock(Piston.class);
engine.setPiston(piston);
// set the expectations
mockery.checking(new Expectations() {{
(Continue reading)
RSS Feed