Stub out
To create a placeholder or simplified version of code, often used for testing or development.
Stubbing out code means creating a basic, temporary version of a function or module. This lets you test other parts of your program that depend on it, even if the real version isn't ready yet.
For example, imagine you're building a weather app. You need to get data from a weather service API. Before you have the real API connection working, you could 'stub out' the weather service. This stub would just return a fixed, made-up weather report (like 'sunny and 70 degrees') whenever your app asks for it. This lets you build and test the rest of your app's display and features without waiting for the actual weather data.
Stubbing out involves replacing a complex or unavailable component with a simplified stand-in, often called a stub. This technique is crucial in software development for unit testing and integration testing. Stubs mimic the behavior of the real component by returning predefined responses, allowing developers to isolate and test specific units of code without external dependencies. The primary tradeoff is that tests using stubs may not reflect the full complexity or potential failure modes of the integrated system.
The term 'stub out' appears in discussions about integrating AI code generation tools like OpenAI's Codex into development workflows. Developers are using stubbing to test AI-generated code or to integrate AI features before the underlying AI models or services are fully deployed or connected.
- Supercharging Codex with JetBrains MCP at SkyscannerOpenAI · OpenAI Developers Blog ·
- OpenAI ChatGPT
- OpenAI's tools like Codex can assist developers in generating code, which might then be stubbed out for testing or integration purposes.
- Mocking
- Mocks are similar to stubs but also verify interactions with the compon
- Dummy data
- Dummy data is a placeholder value used to fill a parameter, whereas
- Fakes
- Fakes are working implementations of a component, often simpler than the
The concept of stubbing originated in the field of software engineering, particularly within the practices of unit testing and test-driven development, to manage dependencies.
When using a coding assistant like GitHub Copilot or OpenAI's Codex, try asking it to write a simple function that calls another function. Then, write a very basic version of the second function yourself that just returns a fixed value. See how your first function works with this simple placeholder.
The Playbook: reusable how-tos, prompts, configs and tips pulled out of the news.
- PromptRole-play a student struggling with math for AI tutor simulationSimulate a student's math struggles and uncertainty for AI tutor evaluation. · 5 min
- TemplateReusable workflow templates for healthcare teamsTeams can create and share templates for common workflows like documentation or prior authorizations. · 15 min
- TemplateTemplate for building an AI tool tailored to your workA structured approach to defining and building a custom AI tool for specific business needs. · 15 min
- TemplateEvals CSV prompt list for agent skillsA CSV file template for listing prompts used in evaluating agent skills. · 20 min
- HeuristicDouble coding agent task completion with docs linksProviding coding agents with a documentation link significantly increases their task completion rate. · 2 min
Questions people ask
- What is the difference between a stub and a mock?
- A stub provides canned answers to calls made during the test. A mock is a mock object that also checks that calls are made to it.
- Why would I stub out code?
- You stub out code to isolate the part you are testing, to simulate behavior that is difficult to produce, or when the code you depend on is not yet available.
First seen on Subvolts Sep 3, 2026. Updated Sep 15, 2026. Written by an AI model from the items above and reviewed against them weekly; report an error.

