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