title: Mockito: How do you verify the group order of certain groups of method calls?
body: <p>I'm using Mockito to verify orders of method calls with the <code>InOrder</code> object. But I am not interested in a total ordering of the calls, only that a certain group of method calls all happen before some other methods are invoked. For example like this</p>
  
  <pre><code>@Test
  public void testGroupOrder() {
      Foo foo1 = mock(Foo.class);
      Foo foo2 = mock(Foo.class);
      Bar underTest = new Bar();
      underTest.addFoo(foo1);
      underTest.addFoo(foo2);
  
      underTest.fire()
  
      InOrder inOrder = inOrder(foo1,foo2);
  
      inorder.verify(foo1).doThisFirst();
      inorder.verify(foo2).doThisFirst();
  
      inorder.verify(foo1).beforeDoingThis();
      inorder.verify(foo2).beforeDoingThis();
  }
  </code></pre>
  
  <p>But this test does test too much, since it tests the order of the <code>Foo</code> instances. But I'm only interested in the order of the different methods. In fact I want <code>underTest</code> to not differentiate the instances of <code>Foo</code>, it may have an internal order on them or not, so it does not matter in which order the foos are called. I'd like to keep that as an implementation detail.</p>
  
  <p>But it is important that <code>doThisFirst()</code> has been called on <em>all</em> of the foos before <code>beforeDoingThis()</code> is invoked on <em>any</em> other foo. Is it possible to express that with Mockito? How?</p>