单测—static方法 静态方法的单测 静态方法的单测 方法上加注解 @PrepareForTest({静态方法所在的类.class}) 调用测试方法前先要mock出类。 @Before public void setUp() throws Exception { PowerMockito.mockStatic(类名.class); } 单测方法中直接使用静态方法 @Test public void test() { when(类名.方法名(参数1, 参数2)).thenReturn(想要返回的结果); }