看一下这篇文章,它解释了如何使用PowerMock和
SpringJUnit4ClassRunner。基本上,您只需要使用一条特殊
PowerMockRule规则:
@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations = "classpath:config/test-applicationContext-config.xml")@TestExecutionListeners({ WebContextTestExecutionListener.class, DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class })public class SpringExampleTest { @Rule public PowerMockRule rule = new PowerMockRule();}编辑:似乎其他人与您有同样的问题
@PowerMockRule。使用PowerMockAgent可以解决您的情况。



