Skip to content

Instantly share code, notes, and snippets.

@siordache
siordache / ISquare.java
Created July 23, 2015 00:45
Spock specification for testing partial mocking of interfaces with default methods
public interface ISquare {
double getLength();
default double getArea() {
return getLength() * getLength();
}
}
@siordache
siordache / PartialMockingAbstractClasses.groovy
Last active August 29, 2015 14:25
Spock specification for testing partial mocking of abstract classes
import spock.lang.Specification
class PartialMockingAbstractClasses extends Specification {
def "Square with stubbed getLength()"() {
given:
Square square = Spy() {
2 * getLength() >> 3
}
when:
def area = square.area