Testing Test Writing

Write behavior-focused unit, integration, and end-to-end tests with mocked dependencies.

6|1|Updated Nov 12, 2022
One-click install
npx skills add https://github.com/coreyja/coreyja.com --skill testing-test-writing-coreyja
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Testing Test Writing
Source: https://github.com/coreyja/coreyja.com/tree/main/.claude/skills/testing-test-writing
Command: npx skills add https://github.com/coreyja/coreyja.com --skill testing-test-writing-coreyja

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides the creation of high-quality, focused, and maintainable tests that verify application behavior, not just implementation details, saving development time and reducing bugs.

Core Features & Use Cases

  • Behavior-Driven Testing: Focuses on what the code does rather than how it does it, leading to more robust and less brittle tests.
  • Comprehensive Coverage: Guides writing unit, integration, and end-to-end tests for critical user flows and business logic.
  • Use Case: After implementing a new user authentication feature, use this skill to generate unit tests for the login function, integration tests for the authentication flow, and an end-to-end test for a successful user login.

Quick Start

Using the Testing Test Writing skill, generate unit tests for the 'calculateTotalPrice' function, ensuring edge cases like zero quantity and negative prices are covered.

Frequently Asked Questions about Testing Test Writing

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

FAQPage Schema
How do I write unit tests that validate behavior instead of implementation?

Behavior-driven unit tests focus on what functions return for given inputs rather than how they work internally. Write assertions on outputs and side effects, use descriptive test names like 'returns total price when quantities are positive', and avoid testing private methods or internal state. This approach makes tests resilient to refactoring.

What's the best way to structure integration tests for authentication flows?

Integration tests validate how components interact across layers. For authentication, test the full login flow from user input through database queries and session creation. Mock external dependencies like email services, use realistic test data, and verify both success and failure paths. Place these tests after unit tests complete.

How do I ensure my tests run fast and deterministically?

Fast, deterministic tests avoid flakiness by isolating external dependencies through mocking, using in-memory databases for integration tests, and eliminating timing-dependent assertions. Keep test scope focused on specific behaviors, run them frequently during development, and avoid shared state between test cases.

Which testing frameworks should I use for unit, integration, and end-to-end tests?

Choose frameworks matching your language: Jest for JavaScript, pytest for Python, RSpec for Ruby, and Rust's built-in test framework for Rust. Each provides assertion libraries, mocking tools, and test runners. Select based on language and project conventions, then apply consistent patterns across all test types.

When should I write end-to-end tests versus unit and integration tests?

End-to-end tests validate critical user workflows through the entire application stack. Write them for high-value flows like checkout or login, after unit and integration tests pass. Use them sparingly since they're slower and more brittle; focus on core business logic rather than exhaustive coverage.

How do I handle edge cases like zero values and negative numbers in tests?

Edge case tests validate boundary conditions and invalid inputs. For a price calculation, test zero quantity, negative prices, and maximum values. Name tests clearly—'returns zero when quantity is zero'—and verify both the calculation result and any error handling. These tests prevent bugs in production.