一键导入
testing-strategies
Design and implement comprehensive testing strategies covering unit, integration, and E2E tests. Maximize coverage and confidence.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Design and implement comprehensive testing strategies covering unit, integration, and E2E tests. Maximize coverage and confidence.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Interactive onboarding workflow that interviews users to understand their coding goals and generates PR-ready implementation plans. Use when starting a new development task to ensure clear requirements and structured execution.
Implement security best practices for Gamma integration. Use when securing API keys, implementing access controls, or auditing Gamma security configuration. Trigger with phrases like "gamma security", "gamma API key security", "gamma secure", "gamma credentials", "gamma access control".
Write effective technical documentation including READMEs, API docs, architecture decisions, and inline code documentation.
Build and manage CI/CD pipelines with Azure DevOps. Configure builds, releases, and automate software delivery workflows.
Develop, deploy, and manage Azure Functions for serverless computing. Supports HTTP triggers, timers, queues, and event-driven architectures.
Manage Azure resources effectively using CLI, Portal, Bicep, and ARM templates. Use for provisioning, organizing, and maintaining cloud infrastructure.
| name | testing-strategies |
| description | Design and implement comprehensive testing strategies covering unit, integration, and E2E tests. Maximize coverage and confidence. |
| triggers | ["/testing","/test strategy"] |
This skill guides you through designing and implementing comprehensive testing strategies including unit tests, integration tests, and end-to-end tests.
Use this skill when you need to:
/\
/ \
/ E2E \ (Few tests, high confidence, slow)
/--------\
/Integration\ (Medium tests, medium confidence)
/--------------\
/ Unit Tests \ (Many tests, fast, focused)
---------------------
Target Distribution
Principles
Example (Python with pytest)
import pytest
def test_calculate_discount_applies_percentage():
# Arrange
price = 100.0
discount_percent = 10
# Act
result = calculate_discount(price, discount_percent)
# Assert
assert result == 90.0
def test_calculate_discount_rejects_negative_price():
with pytest.raises(ValueError, match="Price must be positive"):
calculate_discount(-10, 10)
Mocking
from unittest.mock import Mock, patch
def test_process_order_sends_notification():
mock_notifier = Mock()
service = OrderService(notification_service=mock_notifier)
service.process_order(order)
mock_notifier.send.assert_called_once_with(
to=order.customer_email,
subject="Order confirmed"
)
Scope
Database Testing
@pytest.fixture
db_session():
# Set up test database
engine = create_engine("postgresql://test:test@localhost/testdb")
yield Session(engine)
# Clean up
engine.execute("TRUNCATE orders, customers")
def test_order_repository_creates_order(db_session):
repo = OrderRepository(db_session)
order = Order(customer_id=1, total=100)
saved_order = repo.save(order)
assert saved_order.id is not None
assert db_session.query(Order).count() == 1
API Testing
def test_create_order_endpoint(client):
response = client.post("/api/orders", json={
"customer_id": 1,
"items": [{"product_id": 1, "quantity": 2}]
})
assert response.status_code == 201
assert response.json()["id"] is not None
assert response.json()["status"] == "pending"
Tools
Example (Playwright)
import { test, expect } from '@playwright/test';
test('user can complete purchase', async ({ page }) => {
// Navigate and login
await page.goto('/login');
await page.fill('[data-testid=email]', 'user@test.com');
await page.fill('[data-testid=password]', 'password');
await page.click('[data-testid=login-button]');
// Add item to cart
await page.goto('/products');
await page.click('[data-testid=add-to-cart]');
// Checkout
await page.goto('/checkout');
await page.fill('[data-testid=card-number]', '4111111111111111');
await page.click('[data-testid=place-order]');
// Verify
await expect(page.locator('[data-testid=success-message]'))
.toBeVisible();
});
Folder Structure
tests/
├── unit/
│ ├── test_models.py
│ ├── test_services.py
│ └── test_utils.py
├── integration/
│ ├── test_repositories.py
│ ├── test_api.py
│ └── test_external_services.py
├── e2e/
│ ├── test_user_flows.spec.ts
│ └── test_admin_flows.spec.ts
└── fixtures/
└── test_data.py
Test Data
Flaky Tests
Coverage
See the examples/ directory for:
unit-test-examples/ - Unit test patterns by languageintegration-test-setup/ - Database and API testinge2e-playwright/ - End-to-end test suitetest-fixtures/ - Reusable test data factories