有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java在Mockito文档中,“SRPy”代表什么

http://docs.mockito.googlecode.com/hg/org/mockito/Mockito.html

As usual you are going to read the partial mock warning: Object oriented programming is more less tackling complexity by dividing the complexity into separate, specific, SRPy objects. How does partial mock fit into this paradigm? Well, it just doesn't... Partial mock usually means that the complexity has been moved to a different method on the same object. In most cases, this is not the way you want to design your application.


共 (1) 个答案

  1. # 1 楼答案

    根据Mockito文件{a1}

    Spying on real objects is often associated with "partial mocking" concept. However, Mockito spies are not partial mocks. Mockito spy is meant to help testing other classes - not the spy itself. Therefore spy will not help if you intend to verify if method calls other method on the same object. In this case I suggest being OO/SRPy (for example you might extract new class/interface...)

    OO指的是面向对象的,SRP指的是单一责任原则。这是一种设计模式,说明类应该有一个且只有一个职责,在这种情况下,您可能会编写不需要测试内部方法是否被调用的代码

    http://en.wikipedia.org/wiki/Single_responsibility_principle