## Stub Object Brief
![[tree-stump.png|100]]
A [[Software construction/Testing/Test Doubles/Test Doubles|Test double]] that feeds the desired indirect input into the [[System Under Test]]. The sub object can save us time and complicated setup by cutting off expensive dependencies.
## Illustration
![[Test-Stub-lifecycle.gif]]
## Examples
- A stub object replaces an object that represents a database connection, feeding back a predefined set of objects when queried. Providing predicable test data, and saving the need for an actual database and database connection
- A stub object replaces an object that makes a request to an third party service outside of the [[System Under Test]]. Providing predicable test data, removing the need to setup the third party service and performing a call that may take a long time and depend on something outside of our control
> Pollards cut at about a metre above the ground are called stubs (or stubbs).
> - https://en.wikipedia.org/wiki/Pollarding
## Sources
http://xunitpatterns.com/Test%20Stub.html