PowerMockito之测试私有方法

类名 fixture = new 类名();
@Test
    public void testCheckLockKeyTimeout() throws Exception {
        类名 spy = PowerMockito.spy(fixture);
        Method checkLockKeyTimeout = PowerMockito.method(类名.class, 方法名, 参数类型.class);//如果多个参数,逗号分隔,然后写参数类型.class
        try {
            checkLockKeyTimeout.invoke(spy,参数);
            System.out.println(a);
        }catch (Exception e){
            System.out.println(e.getMessage());
        }

    }

 

你可能感兴趣的:(PowerMockito,Junit,PowerMockito,JUnit测试私有方法,UT编写私有方法)