Spock 1.1 has been released today and includes a series of new features and improvements. One of them, which is my contribution, is the ability to create partial mocks for Java 8 interfaces that contain default methods.
Let’s see how it works:
By creating a spy for the ISquare interface and mocking the getLength() method, we are able to test the default implementation of the getArea() method.
Nothing surprising here. It’s probably exactly what you expected. But it didn’t work with Spock version 1.0 or earlier.