test-patterns

Generates unit and integration tests following language-specific patterns and coverage strategies.

Updated Jan 8, 2026
One-click install
npx skills add https://github.com/jayteealao/OtterStack --skill test-patterns-jayteealao
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: test-patterns
Source: https://github.com/jayteealao/OtterStack/tree/main/.claude/skills/test-patterns
Command: npx skills add https://github.com/jayteealao/OtterStack --skill test-patterns-jayteealao

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing consistent, maintainable tests is time-consuming, and teams often struggle with poor test structure, excessive mocking, and misleading coverage metrics. This Skill provides proven patterns for generating and organizing tests across Python, TypeScript, and Ruby. ## Core Features & Use Cases - Unit Test Generation: Apply Arrange-Act-Assert structure, mocking patterns, fixtures, and parametrized tests for pytest, Jest/Vitest, and RSpec. - Integration & API Testing: Create request/response tests, authentication tests, database transaction tests, and external service contract tests. - Test Data Factories: Build factories with Factory Boy, FactoryBot, or faker-based TypeScript factories for consistent test data. - Coverage Strategies: Implement risk-based coverage targets, branch coverage, and mutation testing to achieve meaningful coverage. - Use Case: When adding a new payment module, use this Skill to generate unit tests with mocked payment gateways, integration tests for the checkout API endpoint, and boundary tests for discount calculations. ## Quick Start Generate unit tests with mocked dependencies for the order calculation module following the project's test conventions.

Frequently Asked Questions about test-patterns

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

FAQPage Schema
How do I write unit tests with mocks in pytest?▼

Use unittest.mock.Mock to replace external dependencies and inject them via constructor parameters. Verify interactions with assert_called_once_with, and use pytest fixtures for shared setup like database sessions and test users.

What is the difference between a mock, stub, and spy?▼

A stub provides canned return values without verification, a mock verifies it was called with specific arguments, and a spy records all calls for later inspection. Choose based on whether you need to verify interactions or just control return values.

How do I create test data factories in Python?▼

Use Factory Boy to define factory classes with Faker-generated attributes, sequences for unique values, and traits for state variations like admin users. Call UserFactory() for defaults or pass overrides for specific scenarios.

Does this approach work with TypeScript and Ruby projects?▼

Yes, the patterns cover TypeScript with Jest/Vitest using vi.fn() mocks and faker-based factories, plus Ruby with RSpec and FactoryBot traits. The core principles like AAA structure and test independence apply across all three languages.

Why do my tests pass but coverage is misleading?▼

High line coverage can hide untested branches and missing edge cases. Use branch coverage, boundary testing, and mutation testing with tools like mutmut or Stryker to verify tests actually catch bugs rather than just executing lines.

When should I avoid heavy mocking in tests?▼

Avoid mocking everything, as tests then only verify mock configuration rather than real behavior. Mock only external services like email or payment APIs, and use real objects for domain logic to keep tests meaningful.