Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does 'SRPy' stand for in the Mockito Documentation

From 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.

like image 402
joshbodily Avatar asked Jun 12 '13 04:06

joshbodily


1 Answers

According tho the Mockito documentation for Spy,

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...)

The OO refers to object-oriented, and SRP refers to Single responsibility principle. It is a design pattern that states the class should have one and only one responsibility, and in this case it you would tend to write code that doesn't need to test if internal methods are called.

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

like image 130
Matt Quigley Avatar answered Oct 10 '22 00:10

Matt Quigley