Join GitHub today
"IllegalArgumentException: source and target are not compatible" if Spy is assigned to variable with interface type #822
When a Spy with a provided instance is created and assigned to a variable that is explicitly declared as having an interface as type, creating the spy fails with an IllegalArgumentException in ReflectionUtil.deepCopyFields . If the variable is explicitly declared as having a class as type, or is defined using "def", then creating the spy works as intended.
The stack trace produced is:
How to reproduce
See testcase at https://github.com/reftel/spock-spy-testcase/tree/master
Additional Environment information
java version "1.8.0_144"