title: Spock verifying an exception thrown by mock together with mock interaction
body: <p>The problem I encountered is when I try to verify in the <code>then</code> block that an exception has been thrown, and that call on a mock has been made. </p>
  
  <p>Look at the setup below:</p>
  
  <pre><code>class B {
      def b(A a) {
          a.a()
      }
  }
  
  class A {
      def a() {
      }
  }
  
  def "foo"() {
      given:
      def a = Mock(A)
      a.a() &gt;&gt; { throw new RuntimeException() }
      B b = new B()
  
      when:
      b.b(a)
  
      then:
      thrown(RuntimeException)
      1 * a.a()
  }
  </code></pre>
  
  <p>The above test fails with message: <code>Expected exception java.lang.RuntimeException, but no exception was thrown</code>, but the code setting up the mock explicitly throws the exception.</p>
  
  <p>Funny enough, if you remove the last line: <code>1 * a.a()</code> the test passes. I didn't have similar problem when putting together another assertions in the then block which don't verify exceptions.</p>
  
  <p>Any ideas what's going on?</p>