by @ctoestreich
given:
assert customer.payments.size() == 0
when:
customer.makePayment()
then:
customer.payments.size() == 1
//Spock
ServiceClass serviceClass = Mock(ServiceClass)
//Mockito
List mockedList = mock(List.class);
//EasyMock
List testDouble = EasyMock.createMock(List.class);
//PowerMock
MyClass myClassMock = PowerMock.createMock(MyClass.class);
Lets Demo This