mocking-test-generator

Generate unit tests that mock HTTP requests, databases, and clocks.

1|2|Updated Mar 10, 2026
One-click install
npx skills add https://github.com/santosomar/general-secure-coding-agent-skills --skill mocking-test-generator-santosomar
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mocking-test-generator
Source: https://github.com/santosomar/general-secure-coding-agent-skills/tree/main/skills/testing/mocking-test-generator
Command: npx skills add https://github.com/santosomar/general-secure-coding-agent-skills --skill mocking-test-generator-santosomar

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill automates the creation of tests that mock external dependencies, such as HTTP APIs, databases, or the system clock, allowing for isolated and reliable unit testing.

Core Features & Use Cases

  • Isolate Units: Mocking helps test a specific piece of code without relying on external systems.
  • Test Edge Cases: Easily simulate error conditions or slow responses from dependencies.
  • Use Case: When testing a function that makes an external API call, use this skill to generate tests that mock the API response, ensuring your function behaves correctly even if the real API is down or slow.

Quick Start

Use the mocking-test-generator skill to create a test that mocks the 'requests.get' function for the provided Python code.

Frequently Asked Questions about mocking-test-generator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write Python unit tests that mock external HTTP requests?

To mock external HTTP requests in Python unit tests, you replace real dependencies like the requests.get function with controllable fakes or stubs. This isolates your code under test, ensuring reliable execution without relying on slow or unavailable external APIs.

What is mocking and when do I need it for pytest?

Mocking is a testing technique that replaces external dependencies like databases and system clocks with controllable fakes. You need mocking for pytest when external services are unreliable, slow, or difficult to trigger, allowing you to isolate code and simulate error paths effectively.

Can I use mocking to test database dependencies and error paths in Python?

Yes, you can use mocking to test database dependencies and error paths in Python. By replacing real databases with controllable spies and stubs, you easily simulate error conditions or slow responses, ensuring your function behaves correctly without needing the actual external service.

How do I simulate slow API responses and error conditions in unit tests?

You simulate slow API responses and error conditions in unit tests by using mocking libraries to replace the real external dependencies with controllable fakes. This allows you to easily trigger and verify how your code handles specific error paths and delayed responses.

Do I need specific mocking libraries to replace real dependencies with stubs?

Yes, you need mocking libraries to replace real dependencies with controllable fakes, stubs, or spies. These libraries provide the necessary framework to intercept calls to external systems like HTTP APIs and databases, ensuring your unit tests remain isolated and reliable.

Why should I use mocking instead of calling live APIs in my unit tests?

You should use mocking instead of calling live APIs to ensure your unit tests are isolated, fast, and reliable. Mocking prevents test failures caused by external services being down or slow, and allows you to effectively test edge cases and error paths that are difficult to trigger on live systems.