log4j를 사용하여 메시지를 기록하고 있으며 log4j 등록 정보는 사용자가 제공합니다. 나는 PropertyConfigurator.configure(Properties)
을 사용하여 사용자가 제공 한 속성을 구성했습니다.PropertyMfigito로 PropertyConfigurator.configure()를 조롱하는 방법?
테스트 사례를 작성하는 동안 PowerMock을 사용하여 PropertyConfigurator
을 모의하고 방법도 구성합니다. configure()
메서드는 void 정적 메서드입니다. 그렇게하려고하면 nullpointer 예외가 발생합니다. 어떻게 할 수 있니?
나는이 작동하지 않습니다
PowerMockito.mockStatic(PropertyConfigurator.class);
PowerMockito.doNothing().when(PropertyConfigurator.class);
PropertyConfigurator.configure(slf4jPropertiesMock);
을하고 노력했다.
가능하다면 PropertyConfigurator.configure(Properties)
을 사용하지 않고 seme 결과를 얻을 수있는 곳에서 다른 방법을 사용할 수 있습니까? 이 경우 단위 테스트가 쉽습니다.