Package org.mockito.internal.junit
Class UnusedStubbingsFinder
java.lang.Object
org.mockito.internal.junit.UnusedStubbingsFinder
Finds unused stubbings
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetUnusedStubbings
(Iterable<Object> mocks) Gets all unused stubbings for given set of mock objects, in order.Gets unused stubbings per location.
-
Constructor Details
-
UnusedStubbingsFinder
public UnusedStubbingsFinder()
-
-
Method Details
-
getUnusedStubbings
Gets all unused stubbings for given set of mock objects, in order. Stubbings explicitily marked as LENIENT are not included. -
getUnusedStubbingsByLocation
Gets unused stubbings per location. This method is less accurate thangetUnusedStubbings(Iterable)
. It considers that stubbings with the same location (e.g. ClassFile + line number) are the same. This is not completely accurate because a stubbing declared in a setup or constructor is created per each test method. Because those are different test methods, different mocks are created, different 'Invocation' instance is backing the 'Stubbing' instance. In certain scenarios (detecting unused stubbings by JUnit runner), we need this exact level of accuracy. Stubbing declared in constructor but realized in % of test methods is considered as 'used' stubbing. There are high level unit tests that demonstrate this scenario.
-