Class UnusedStubbingsFinder


  • public class UnusedStubbingsFinder
    extends java.lang.Object
    Finds unused stubbings
    • Constructor Detail

      • UnusedStubbingsFinder

        public UnusedStubbingsFinder()
    • 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 than getUnusedStubbings(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.