Test double patterns
Last updated
Last updated
Test Double: How can we verify logic independently when code it depends on is unusable? How can we avoid Slow Tests? We replace a component on which the SUT depends with a “test-specifi c equivalent.”
We replace a real object with a test-specifi c object that feeds the desired indirect inputs into the system under test.
We use a Test Double to capture the indirect output calls made to another component by the SUT for later verification by the test.
We replace an object on which the SUT depends on with a test-specifi c object that verifi es it is being used correctly by the SUT
We replace a component that the SUT depends on with a much lighter-weight implementation.
We confi gure a reusable Test Double with the values to be returned or verifi ed during the fi xture setup phase of a test.
We build the Test Double by hard-coding the return values and/or expected calls.