Package org.mockito.internal.junit
Class UnusedStubbingsFinder
- java.lang.Object
-
- org.mockito.internal.junit.UnusedStubbingsFinder
-
public class UnusedStubbingsFinder extends java.lang.Object
Finds unused stubbings
-
-
Constructor Summary
Constructors Constructor Description UnusedStubbingsFinder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UnusedStubbings
getUnusedStubbings(java.lang.Iterable<java.lang.Object> mocks)
Gets all unused stubbings for given set of mock objects, in order.java.util.Collection<Invocation>
getUnusedStubbingsByLocation(java.lang.Iterable<java.lang.Object> mocks)
Gets unused stubbings per location.
-
-
-
Method Detail
-
getUnusedStubbings
public UnusedStubbings getUnusedStubbings(java.lang.Iterable<java.lang.Object> mocks)
Gets all unused stubbings for given set of mock objects, in order. Stubbings explicitily marked as LENIENT are not included.
-
getUnusedStubbingsByLocation
public java.util.Collection<Invocation> getUnusedStubbingsByLocation(java.lang.Iterable<java.lang.Object> mocks)
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.
-
-