In order to develop test-driven programming, JUnit has been essential. doReturn(...) and thenReturn(...) are Mockito methods which can be used to stub method calls. The major difference between doReturn(...) and thenReturn(...) is that doReturn(...) is used for void methods while thenReturn(...) can be used for non-void methods. do Return: When we use do Return, it means we are telling Mockito that the stubbed method should return a value without executing the actual method. For example, if we have a void method which updates a record in the database, we can use do Return to stub the method so that it does not update the database. We can also use do Return to stub a method which throws an exception. In this case, Mockito will not throw the exception when we call the stubbed method. It will simply return the exception object. then Return:When we use then Return, it means we are telling Mockito to first execute the actual method and then return a value. This is useful when we want to test methods which depend on the output of other methods. For example, if we have a non-void method which calculates the sum of two numbers, we can use then Return to stub the method so that it returns the sum of the two numbers. We cannot use then Return to stub void methods or methods which throw exceptions.