A stub is a little piece of code used in testing to replace another component. Using a stub has the advantage of returning consistent results, which makes the test easier to construct. And tests can be performed even if the other components are not yet operational.