单元测试--MOCK静态方法

来源:互联网 发布:淘宝买家怎样修改差评 编辑:程序博客网 时间:2024/05/21 07:57
@RunWith(PowerMockRunner.class)@PrepareForTest(A.class)public class Test {private B b = new B();    @Test(expected = IllegalStateException.class)    public void testIOException() throws Exception {   PowerMockito.mockStatic(A.class);   PowerMockito.when(A.method()).thenThrow(new IOException());   b.service();    }}
原创粉丝点击