Mockito when() method It enables stubbing methods. It should be used when we want to mock to return specific values when particular methods are called . In simple terms, “When the XYZ() method is called, then return ABC.” It is mostly used when there is some condition to execute.