EasyMock / PowerMock导入问题
我遇到了一些我不太明白的问题,我发现一个网站建议如果模拟是使用 PowerMock 创建的,则存在与 verify() 不兼容的问题。
当我输入一行来创建模拟时,Eclipse 告诉我该方法不明确,我最终不得不将其指定为 EasyMock.createMock 或 PowerMock.createMock。
我最初刚开始使用 EasyMock,然后切换到 PowerMock。 import 语句的顺序重要吗?如果您使用 PowerMock,不包含某些 EasyMock 内容是否重要?
这是我得到的信息:
import org.easymock.EasyMock;
import org.junit.*;
import org.junit.runner.RunWith;
import static org.easymock.EasyMock.*;
import static org.powermock.api.easymock.PowerMock.*;
import org.powermock.reflect.Whitebox;
import org.powermock.api.easymock.*;
import org.powermock.api.easymock.PowerMock.*;
import org.powermock.api.mockito.expectation.*;
import org.powermock.api.mockito.*;
import org.powermock.api.support.membermodification.*;
import org.powermock.api.support.membermodification.MemberMatcher.*;
import org.powermock.core.classloader.annotations.*;
import org.powermock.modules.junit4.*;
那里可能有一些裁员。有可能发生冲突吗?为了消除歧义,顺序重要吗?
谢谢。
克雷格
I'm experiencing some problems I can't quite figure out, and one site I found suggested a problem with incompatibilities with verify() if the mocks were created with PowerMock.
When I type a line to create a mock, Eclipse is telling me the method is ambiguous, and I end up having to specify it as EasyMock.createMock or PowerMock.createMock.
I had originally just started with EasyMock and then switched to PowerMock. Does the order of import statements matter, and if you're using PowerMock is it important not to include certain EasyMock stuff?
Here's what I've got:
import org.easymock.EasyMock;
import org.junit.*;
import org.junit.runner.RunWith;
import static org.easymock.EasyMock.*;
import static org.powermock.api.easymock.PowerMock.*;
import org.powermock.reflect.Whitebox;
import org.powermock.api.easymock.*;
import org.powermock.api.easymock.PowerMock.*;
import org.powermock.api.mockito.expectation.*;
import org.powermock.api.mockito.*;
import org.powermock.api.support.membermodification.*;
import org.powermock.api.support.membermodification.MemberMatcher.*;
import org.powermock.core.classloader.annotations.*;
import org.powermock.modules.junit4.*;
There may be some redundancies there. Is a conflict possible? And is the order important in order to eliminate the ambiguity?
Thanks.
Craig
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
取自
PowerMock
示例请注意,它们不会从这两个库导入 createMock。您不应从已使用
PowerMock
的EasyMock
导入任何内容。Taking from a
PowerMock
exampleNotice that they don't import createMock from both libraries. You shouldn't import anything from
EasyMock
that you are already usingPowerMock
for.