Cookbook¶
Practical, copy-paste recipes for integrating pytest-gremlins into your projects.
What is the Cookbook?¶
The cookbook provides complete, ready-to-use configurations for common scenarios. Each recipe includes:
- Goal - What you're trying to achieve
- Prerequisites - What you need before starting
- Steps - Numbered, copy-paste instructions
- Configuration - Complete config files (not snippets)
- Verification - How to confirm it works
- Troubleshooting - Common issues and fixes
Available Recipes¶
CI/CD Integration¶
| Recipe | Description |
|---|---|
| GitHub Actions | Complete workflow with caching and matrix builds |
| GitLab CI | Pipeline with stages and artifacts |
| CircleCI | Orb-based configuration with parallelism |
Project Types¶
| Recipe | Description |
|---|---|
| Django Projects | Models, views, and Django-specific settings |
| FastAPI Projects | Async code, dependency injection, API endpoints |
| Monorepo Setup | Multi-package repos with selective testing |
Development Workflow¶
| Recipe | Description |
|---|---|
| TDD Workflow | Red-Green-Refactor-Mutate cycle |
| Pre-commit Hook | Fast incremental runs on commit |
| pytest Plugin Compatibility | Integration with pytest-cov, pytest-xdist |
Quick Reference¶
Minimum Configuration¶
Run Mutation Testing¶
Bash
# Basic run
pytest --gremlins
# With HTML report
pytest --gremlins --gremlin-report=html
# Quick run (comparison operators only)
pytest --gremlins --gremlin-operators=comparison
# With incremental caching
pytest --gremlins --gremlin-cache
Common Command Patterns¶
Bash
# Development: fast feedback on changed code
pytest --gremlins --gremlin-cache
# CI: full run with report
pytest --gremlins --gremlin-report=html
# Debug: single file
pytest --gremlins --gremlin-targets=src/mymodule.py
# Performance: parallel execution
pytest --gremlins --gremlin-parallel --gremlin-workers=4
Getting Help¶
- Configuration Reference - All configuration options
- Operators Guide - Available mutation operators
- GitHub Issues - Report problems or request features