阅读背景:

如何模拟单件工厂的对象创建?

来源:互联网 

The example I tried to follow:

我试图遵循的例子:

@PrepareForTest(X.class)
public class XTest extends PowerMockTestCase {
        @Test
        public void test() {
                whenNew(MyClass.class).withNoArguments().thenThrow(new IOException("error message"));

                X x = new X();
                x.y(); // y is the method doing "new MyClass()"

                ..
        }
}
@P



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: