Skip to content
Latchkey

Stub - CI/CD Glossary Definition

A stub is a test double that returns predefined responses to calls made during a test, with no logic of its own, so the code under test gets controlled inputs.

Typical use

You stub a slow or external call (an HTTP client returning fixed JSON) so the test runs fast and deterministically and exercises a specific code path, like the error branch.

Stub vs mock

A stub provides answers but makes no assertions; a mock provides answers and verifies it was called as expected. Choose a stub when you care about output, a mock when you care about the interaction.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →