The problem I am facing is when I try to check in the then block that an exception was thrown and that call was made.
Take a look at the installation below:
class B { def b(A a) { aa() } } class A { def a() { } } def "foo"() { given: def a = Mock(A) aa() >> { throw new RuntimeException() } B b = new B() when: bb(a) then: thrown(RuntimeException) 1 * aa() }
The above test failed with the message: Expected exception java.lang.RuntimeException, but no exception was thrown , but the code setting the layout explicitly throws an exception.
It's funny if you delete the last line: 1 * aa() test will pass. I did not have a similar problem when combining other statements in the then block that do not check for exceptions.
Any ideas what is going on?
mocking groovy spock
jarzeb
source share