testing

Automate pytest and unittest testing patterns for Python projects.

18|2|Updated Dec 12, 2025
One-click install
npx skills add https://github.com/Lobbi-Docs/claude --skill testing-lobbi-docs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/Lobbi-Docs/claude/tree/main/.claude/skills/testing
Command: npx skills add https://github.com/Lobbi-Docs/claude --skill testing-lobbi-docs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires extended-thinking, deep-analysis, debugging.

What problem does it solve?

This Skill guides you in designing comprehensive test strategies, writing effective unit and integration tests, and applying advanced techniques like property-based and mutation testing to ensure high code quality and prevent regressions.

Core Features & Use Cases

  • Pytest & Mocking: Write Pytest-based tests, use fixtures, and mock dependencies for isolated testing.
  • Hypothesis-Driven Development: Formulate testable hypotheses and design experiments to validate system behavior.
  • Property-Based Testing: Verify system invariants by generating random inputs with Hypothesis.
  • Use Case: You're refactoring a critical authorization module. Use this skill to apply a "Refactoring Test Strategy," ensuring all existing behaviors are preserved, new abstractions are correct, and performance hasn't regressed, all while running a full test suite before and after changes.

Quick Start

Use the testing skill to generate a pytest unit test for a function named 'calculate_discount' that takes 'price' and 'customer_type'.

Frequently Asked Questions about testing

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

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

Unit tests in pytest are functions prefixed with `test_` that verify individual components. Write assertions to check expected behavior, use fixtures for setup and teardown, and run `pytest` to execute your test suite. This isolates code units and catches regressions early.

What's the difference between unit tests and integration tests?

Unit tests verify individual functions or classes in isolation using mocks to stub dependencies. Integration tests verify multiple components working together with real or near-real interactions. Both are essential: unit tests catch logic bugs fast, integration tests validate system behavior end-to-end.

How do I mock dependencies and use fixtures in pytest?

Fixtures provide reusable test setup via `@pytest.fixture` decorated functions; pass them as test arguments. Mocking isolates code by replacing real dependencies with controlled substitutes using libraries like `unittest.mock`. This enables testing specific logic without external services or databases.

Can I measure test coverage in Python projects?

Test coverage reports show what percentage of your code is executed by tests using tools like `coverage.py`. Run `coverage run -m pytest` then `coverage report` to identify untested branches and gaps. High coverage reduces the risk of bugs reaching production.

What is property-based testing and when should I use it?

Property-based testing with Hypothesis generates random inputs to verify system invariants and edge cases automatically. Instead of writing specific test cases, you define properties that must always hold true. Use it for mathematical functions, data transformations, and algorithms to catch unexpected failures.

How do I integrate tests into CI/CD workflows?

Configure your CI/CD pipeline to run `pytest` and coverage checks on every commit or pull request. Fail the build if tests don't pass or coverage drops below a threshold. This prevents untested code from merging and ensures code quality gates are enforced automatically.