import spock.lang.* // Hit 'Run Script' below class MyFirstSpec extends Specification { def 'stub a method with collection as argument'() { given: def input = [1, 2, 3] def capturedArgument List listStub = Stub() listStub.addAll(input) >> { capturedArgument = it } when: listStub.addAll(input) then: input.class == capturedArgument.class } }