조롱 模拟 개인 정적을 최종 이제 = system.currentmills을;
첫째, 테스트 클래스의 시작 부분에 플러스 :
@prepareForTest ({} System.class)
클래스 A {
}
이어서, 추가의 방법에서 :
powermockito.mockstatic (system.class)
powermockito.when (system.currentmills) .thenreturn (지금)
system.currentmills;
모의 시뮬레이션 변수 클래스 A {
개인 문자열 a를;
}
그것은 할 수있다 :
문자열 A = "테스트";
ReflectionUtils.set (새 A (), 'A', A);
모의 시뮬레이션 변수 클래스 A {
민간 최종 문자열 a를;
}
그것은 할 수있다 :
문자열 A = "테스트";