title: Use Mockito to verify that nothing is called after a method
body: <p>I'm using Mockito to write a unit test in Java, and I'd like to verify that a certain method is the <em>last one</em> called on an object.</p>
  
  <p>I'm doing something like this in the code under test:</p>
  
  <pre><code>row.setSomething(value);
  row.setSomethingElse(anotherValue);
  row.editABunchMoreStuff();
  row.saveToDatabase();
  </code></pre>
  
  <p>In my mock, I don't care about the order in which I edit everything on the row, but it's very important that I <em>not</em> try to do anything more to it after I've saved it. Is there a good way to do this? </p>
  
  <p>Note that I'm not looking for verifyNoMoreInteractions: it doesn't confirm that saveToDatabase is the last thing called, and it also fails if I call anything on the row that I don't explicitly verify. I'd like to be able to say something like:</p>
  
  <pre><code>verify(row).setSomething(value);
  verify(row).setSomethingElse(anotherValue);
  verifyTheLastThingCalledOn(row).saveToDatabase();
  </code></pre>
  
  <p>If it helps, I'm switching to Mockito from a JMock test that did this:</p>
  
  <pre><code>row.expects(once()).method("saveToDatabase").id("save");
  row.expects(never()).method(ANYTHING).after("save");
  </code></pre>