【发布时间】:2013-11-12 00:25:01
【问题描述】:
代码发布在link
现在,当我尝试编写 junit 时 第一种情况我收到错误
“需要重播B类”。
但同样的 junit 正在为第二种情况工作。
我的junit是
@RunWith(PowerMockRunner.class)
public class TestClass {
@Test
public void testDoSomeThing() {
B b = createMock(B.class)
expectNew(b.CallMe()).andReturns(xxx)
A a=new A();
replayAll();
a.doSomething();
verifyAll();
}
}
【问题讨论】:
-
你能发布你的 JUnit 测试吗?
-
你在哪里看到这个错误?那是你得到的确切字符串吗?
-
@all 粘贴了我的 junit 类
-
在此处发布之前格式化您的代码,帮自己一个忙。
-
java.lang.IllegalStateException: 必须重播类 xxxx 以获得配置的期望。在 org.powermock.api.easymock.internal.invocationcontrol.NewInvocationControlImpl.invoke(NewInvocationControlImpl.java:60) 在 org.powermock.core.MockGateway.newInstanceCall(MockGateway.java:169) 这是我得到的确切堆栈跟踪
标签: java unit-testing junit junit4 powermock