Skip to content

Feature request/idea - "No more interactions" for a single method only #501

Description

@GoogleCodeExporter
What steps will reproduce the problem?

I need to verify interaction with a mock, but ignoring most of mock's method 
calls except for one. And for that important method, I would like to be able to 
assert "verify no more interactions".

Currently there is no way to do that - verifyNoMoreInteractions() considers all 
method invocations, not just some particular one. I also tried to use inOrder + 
never() but it only lets me catch unexpected interactions at the end of the 
chain of calls. InOrder does not catch cases when extra interactions happen for 
the same method, i.e.

inOrder.verify(mock).call(1);
inOrder.verify(mock).call(3);
inOrder.verify(mock, never()).call(anyInt());

with the code under test does not catch invocation #2:

m.call(1);
m.call(2); // not caught!
m.call(3);
m.call(4); // caught!

What is the expected output? What do you see instead?

This is perfectly understandable for inOrder, however it would be nice to be 
able to verify that some method is no longer called, regardless of other 
methods... either as a feature of inOrder, which limits it to 1 method only, or 
as a feature of verifyNoMoreInteractions() where specific methods are being 
checked, not all methods of a mock(s).

What version of the product are you using? On what operating system?

Mockito 1.9.0, RHEL5

Original issue reported on code.google.com by b.traffi...@gmail.com on 12 Sep 2014 at 8:03

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions