package com.example.dev;
public class AClass {
private Integer a =10;
...//other code
}
,当我尝试访问我的斯波克方法:为什么可以在没有问题的情况下测试Spock中的私有方法/字段?
package com.example.dev;
def 'test a'() {
AClass aClassVar = new AClass()
aClassVar.a = new Integer(100);
...//other testing stuff
}
它工作正常。为什么会发生? Spock是否使用反射访问私有字段?或者我的封装写得不好?