I wanna spy method calls of Spring bean. I checked docs - Spock can create spy only by constructor. Can Spock wrap already existing object by spy?
It seems that it can't be done because of the fact that API doesn't support it. Have a look at API. The following piece of code runs with errors:
@Grab('org.spockframework:spock-core:0.7-groovy-2.0')
@Grab('cglib:cglib-nodep:3.1')
import spock.lang.*
class Test extends Specification {
def 'test'() {
given:
def o = new Object()
def s = Spy(o)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With