We think you might be interested in this job:
This article will help you differentiate between a Dummy, a Stub and a Mock. To explain the difference between a mock, a stub or a dummy, we will first see their definitions. A dummy is an empty class that we can use when we need to instantiate an object dependent on it.It aims to make believe that a class exists to the one that we want to test.It is usually passed as a parameter but never called.If called, its functions will always return null. A Stub is a dummy that will be customizable.It will correspond to what we expect.He can redefine his methods and tell him what to return. A mock is a duplicate that checks expectations.We can make it check that the method is called x times like never.If the simulation is not done as many times as expected the test will fail.Unlike the Stub a Mock can throw exceptions if it does not receive the correct calls.The purpose of the mock is not to be interested in the return value but rather to be interested in the method which is called and to know how many times and with what arguments.