@RunWith(JMock.class)
public class ChildTest {
Mockery context = new JUnit4Mockery();
States test = mockery.states("test");
Parent parent = context.mock(Parent.class);
// This is created in setUp
Child child;
@Before
public void createChildOfParent() {
mockery.checking(new Expectations() {{
ignoring (parent).addChild(child); when(test.isNot("fully-set-up"));
}});
// Creating the child adds it to the parent
child = new Child(parent);
test.become("fully-set-up");
}
@Test
public void removesItselfFromOldParentWhenAssignedNewParent() {
Parent newParent = context.mock(Parent.class, "newParent");
context.checking(new Expectations() {{
oneOf (parent).removeChild(child);
oneOf (newParent).addChild(child);
}});
child.reparent(newParent);
}
}What is mockery
variable? Did you mean context and it's a misprint? or I'm getting it the wrong way?Hello noam@fashion-traffic.com
You have successfully subscribed to user@jmock.codehaus.org using this email address.
Thanks,
Codehaus