在Java中创建模拟对象的最佳框架是什么?为什么?每个框架的优缺点是什么?
这是我最初尝试使用JMockIt时发现的.我必须承认,我发现JMockIt文档非常简洁,因为它提供了什么,因此我可能错过了一些东西.尽管如此,这是我所理解的:
Mockito: List a = mock(ArrayList.class) does not stub out all methods
of List.class by default. a.add("foo") is going to do the usual thing
of adding the element to the list.
JMockIt: @Mocked ArrayList<String> a;
It stubs out all the methods of a by default. So, now a.add("foo")
is not going to work.
This seems like a very big limitation to me in JMockIt.
How do I express the fact that I only want you to give me statistics
of …我来自PHP测试世界,我开始用Java进行测试.
我在JUnit中看到了几个模拟SUT的工具,比如Mockito,SevenMock,ClassMock等.
我真的很感激我应该使用哪一个建议.
提前致谢!