클래스의 정적 메서드를 조롱하고 테스트에서 해당 조롱 된 메서드를 사용해야합니다. 지금 당장 PowerMock 만 사용할 수 있습니다.PowerMockRunner가 JUnit ClassRules을 적용하지 않음
@RunWith (PowerMockRunner.class)로 클래스에 주석을 추가하고 @PrepareForTest에 적절한 클래스를 주석으로 지정합니다.
내 테스트에는 @ClassRule이 있지만 테스트를 실행할 때 규칙이 제대로 적용되지 않습니다.
어떻게해야합니까?
RunWith(PowerMockRunner.class)
@PowerMockIgnore({
"javax.xml.*",
"org.xml.*",
"org.w3c.*",
"javax.management.*"
})
@PrepareForTest(Request.class)
public class RoleTest {
@ClassRule
public static HibernateSessionRule sessionRule = new HibernateSessionRule(); // this Rule doesnt applied
추적 용도 : https://github.com/powermock/powermock/issues/687. PowerMock은 기본적으로 JUnit 테스트 처리를 중단하고이를 해결할 실제 계획은 없습니다. –