一键导入
testing
Playbook for executing unit and integration tests, mocking external services, and structuring test suites.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Playbook for executing unit and integration tests, mocking external services, and structuring test suites.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Playbook for capturing design alignment from /grill-me, generating issue specifications, and managing task boards.
Playbook instructing agents how to dynamically formulate, design, bootstrap, and register new workspace skills when facing skill gaps.
Playbook for translating natural language requests about tasks, profiles, locking, and validation into CLI helper executions.
Playbook for writing safe database migrations, managing schema evolutions, executing reversible rollbacks, and avoiding table lock contention in enterprise environments.
Guidelines for CPU profiling, identifying database query bottlenecks (N+1 queries), diagnosing memory leaks, and optimizing resource execution speeds.
Guidelines for containerization (Dockerfile best practices), release versioning, blue-green deployment, feature flag rollouts, and post-deployment smoke verification.
| name | testing |
| description | Playbook for executing unit and integration tests, mocking external services, and structuring test suites. |
This playbook establishes the guidelines, strategies, and patterns for implementing testing and test automation at an enterprise scale, ensuring code safety, reliability, and zero-regression deployments without unnecessary overhead.
To maintain a fast and reliable CI/CD pipeline, tests are divided into two tiers (E2E testing is omitted to optimize token usage and avoid redundant runtime overhead):
Mocking is essential for isolation, but over-mocking leads to fragile tests that fail to detect real integration bugs.
from unittest.mock import patch, MagicMock
# Best Practice: Patch at the import location, not definition location
@patch('module_under_test.external_api_call')
def test_fetch_user_data(mock_api):
# Setup mock return value
mock_api.return_value = {"id": 1, "name": "John Doe"}
result = module_under_test.get_user(1)
assert result["name"] == "John Doe"
mock_api.assert_called_once_with(1)
To keep tests clean and maintainable:
tests/ directory at the root of the project.test_ prefix (e.g., test_auth.py, test_utils.py).test_ followed by the action and expected behavior (e.g., test_authenticate_with_invalid_credentials_fails).assert True.