Let’s share what is the best answer to this interview question.
What is the difference between Stub and Mock conditions while in the development environments?
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Leone Costa
Stub
• Provides fixed behavior under the right condition.
• Provides a dummy object which assists in the running of a test.
• Any other behavior of the stub is never tested
In an example, for an empty stack it is possible to create a stub which just returns true for empty () method.
This is a dummy object in which particular properties are initially set:
• The behavior of this object would be dependent on the set properties
• The behavior of the object may also be tested.
You can set the age of a user as 12 and then test for isAdult() method which will either return true for the age that is greater than 18. The Mock Customer object would work for specified conditions.