一键导入
testing-patterns
Unit testing and integration testing best practices
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Unit testing and integration testing best practices
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
INVOKE THIS SKILL when building evaluation pipelines for LangSmith. Covers three core components: (1) Creating Evaluators - LLM-as-Judge, custom code; (2) Defining Run Functions - how to capture outputs and trajectories from your agent; (3) Running Evaluations - locally with evaluate() or auto-run via LangSmith. Uses the langsmith CLI tool.
INVOKE THIS SKILL when working with LangSmith tracing OR querying traces. Covers adding tracing to applications and querying/exporting trace data. Uses the langsmith CLI tool.
INVOKE THIS SKILL when you need human-in-the-loop approval, custom middleware, or structured output. Covers HumanInTheLoopMiddleware for human approval of dangerous tool calls, creating custom middleware with hooks, Command resume patterns, and structured output with Pydantic/Zod.
INVOKE THIS SKILL at the START of any LangChain/LangGraph/Deep Agents project, before writing any agent code. Determines which framework layer is right for the task: LangChain, LangGraph, Deep Agents, or a combination. Must be consulted before other agent skills.
ALWAYS START HERE for any LangChain, Deep Agents, or LangGraph agent building project. Required starting point before choosing other skills or writing any code. Covers framework selection (LangChain vs LangGraph vs Deep Agents), agent archetypes, dependency setup, and which skills to load next based on your decisions.
INVOKE THIS SKILL when building ANY Deep Agents application. Covers create_deep_agent(), harness architecture, SKILL.md format, and configuration options.
| name | testing-patterns |
| description | Unit testing and integration testing best practices |
Write effective, maintainable tests using modern patterns.
def test_user_registration():
# Arrange
user_data = {"email": "test@example.com", "password": "secure123"}
# Act
result = register_user(user_data)
# Assert
assert result.success is True
assert result.user.email == "test@example.com"
from unittest.mock import Mock, patch
@patch('services.email.send_email')
def test_sends_welcome_email(mock_send):
mock_send.return_value = True
register_user({"email": "test@example.com"})
mock_send.assert_called_once_with(
to="test@example.com",
template="welcome"
)
import pytest
from factories import UserFactory
@pytest.fixture
def user():
return UserFactory.create(role="admin")
@pytest.fixture
def authenticated_client(user):
client = TestClient(app)
client.login(user)
return client
def test_admin_dashboard(authenticated_client):
response = authenticated_client.get("/admin")
assert response.status_code == 200
@pytest.mark.integration
def test_full_checkout_flow(db_session, stripe_mock):
# Create test data
user = create_user()
product = create_product(price=100)
# Execute flow
cart = add_to_cart(user, product)
order = checkout(cart, payment_method="card")
# Verify
assert order.status == "completed"
assert stripe_mock.charges.create.called