내 프로젝트의 일부 정적 메서드에 대한 단위 테스트 케이스를 작성하고 싶습니다.
내 수업 코드 스 니펫,
Class Util{
public static String getVariableValue(String name)
{
if(isWindows()){
return some string...
}
else{
return some other string...
}
}
public static boolean isWindows(){
if(os is windows)
return true;
else
return false;
}
}
기본적으로 isWindows ()가 'false'를 반환 할 때 getVariableValue ()에 대한 단위 테스트 케이스를 작성하고 싶습니다. powermock을 사용하여 어떻게 작성합니까?
// This is the way to tell PowerMock to mock all static methods of a
// given class
PowerMock.mockStaticPartial(Util.class,"isWindows");
expect(Util.isWindows()).andReturn(false);
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다