Is it possible to set an expectation of zero interactions with a mock using JMock

333 Views Asked by At

I am new to JMock, however I have used Mockito before.

I want to assert that a mock has not been used during one of my tests. In Mockito I would use verifyZeroInteractions.

Is there an equivalent in JMock, or do I have to check each of the declared methods?

I am using JMock 2.5.1.

1

There are 1 best solutions below

2
On BEST ANSWER

There is an equivalent:

mockery.checking(new Expectations() {{
    never(mockObject);
}});

If you want to check that a specific method has not been called on your mock:

mockery.checking(new Expectations() {{
    never(mockObject).yourSpecificMethod();
}});

(And well done for using JMock, that's my favourite mocking framework)