0
powermock을 사용하여 클래스의 생성자를 억제 할 때 개인 최종 필드의 값을 어떻게 설정할 수 있습니까?PowerMock - 생성자를 억제하지만 개인 최종 필드를 설정하십시오.
생성자 억제 :
suppress(constructor(ABC.class, MyType.class));
ABC abc = spy(new ABC(null)); // using the correct value doesn't work
abc.someMethod();
클래스 검사 할 수 있습니다 :
class ABC {
private final MyType test;
public ABC(MyType test) {
this.test = test;
// executes code to be suppressed
}
public void someMethod() {
test.doSomethingElse();
}
}