/quality-engineering:test-strategyfrom quality-engineering
Designs test strategies and architectures, balancing unit vs integration vs E2E tests, choosing frameworks, and implementing contract testing between services.
Ships in quality-engineering. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A comprehensive framework for designing test strategies, selecting the right testing approaches for different architectures, and building test suites that provide genuine confidence without becoming a maintenance burden.
Core principle: A test strategy is not a list of tools — it is an architectural decision about where to invest testing effort to maximize confidence per unit of maintenance cost.
The right test distribution is determined by your system architecture, not by dogma. Three models plus one risk framework:
/\
/E2\ ← Narrow: expensive, slow, flaky — use sparingly
/----\
/ Int \ ← Middle layer: module interactions
/--------\
/ Unit \ ← Wide base: fast, isolated, cheap
/____________\
Best for: monolithic applications where unit-level isolation is cheap and highly informative.
/\
/E2\
/----\
/ Inte-\ ← LARGEST LAYER: integration tests dominate
/ gration\
/----------\
/ Unit \
/--------------\
/ Static Analysis\ ← Foundation: linting, type checking
/___________________\
Best for: API-centric and frontend-heavy applications.
Key insight (Guillermo Rauch): "The more your tests resemble the way your software is used, the more confidence they can give you." For APIs, an integration test that calls through the HTTP layer with a real database gives far more confidence than 20 unit tests on isolated functions.
○ ○ ○ ○ ○ ← E2E: minimal, highest-value journeys only
○ ○ ○ ○ ○ ○ ○
○ ○ ○ INTEGRA- ○ ← Dominates: inter-service is the main risk
○ ○ TION ○ ○ ○ ○
○ ○ ○ ○ ○ ○ ○
○ ○ ○ ○ ○ ← Unit: only for isolated business logic
Best for: microservices architectures.
Unit tests for pure business logic (algorithms, transformations, domain rules). Integration tests for everything involving service boundaries — database queries, message queues, HTTP clients. E2E tests only for the most critical cross-service user journeys.
Why Honeycomb: In microservices, the complexity lives between services. A unit test of the order service tells you nothing about whether it integrates correctly with inventory. The inter-service integration is where bugs live.
The Swiss Cheese model is not a distribution — it is a risk framework for explaining why layered testing is necessary. Use this with stakeholders.
Static Unit Integration Contract E2E Monitoring
| | | | | |
[■■□■] [■□■■] [□■■■] [■■□■] [■□□■] [■■■□]
Defects escape to production only when holes align across ALL layers.
Each layer has gaps (the "holes"):
No single layer is sufficient. Defects escape when holes align. The goal is to ensure holes rarely align.
Use this model in risk conversations: "We don't have contract tests, which means our Swiss Cheese model has a full hole in that layer. Any provider API change will escape through to production."
Google's SMURF framework (October 2024, Google Testing Blog) evaluates test portfolio health across five dimensions:
| Dimension | Evaluation Question | Healthy | Unhealthy |
|---|---|---|---|
| Speed | How fast is the suite? | Unit < 5 min; Full suite < 30 min | Any test blocking CI for > 1 hour |
| Maintainability | How easy to understand and change? | Test reads like documentation | Requires deep context to understand what's being tested |
| Utilization | How often are tests actually run? | All tests run on every PR | Significant tests only run on main or nightly |
| Reliability | How consistent are results? | < 2% flake rate per test | Retries regularly needed; "it passed on the retry" |
| Fidelity | How closely does the test simulate real usage? | Integration tests use real data formats and flows | Everything mocked; tests don't represent real behavior |
A test suite can score well on coverage while failing SMURF. A 90% coverage suite where half the tests are slow, flaky, and mock everything is worse than a 60% coverage suite where every test is fast, stable, and meaningful.
Run a SMURF audit quarterly. Each dimension can degrade independently without coverage numbers moving.
When to use: Building new code where the design is uncertain. TDD drives good design by making you write tests first — the resulting code must be testable by construction.
Cycle: Red → Green → Refactor
London School (Mockist): Mock all collaborators; test in strict isolation. Best for legacy code with unclear boundaries. Chicago School (Classicist): Use real objects; mock only I/O boundaries. Best for new code with well-defined domain.
Not a good fit for: exploratory work where the requirements themselves are unclear; UI testing; performance testing.
When to use: When you want test specifications that non-technical stakeholders can read and verify. BDD tests document behavior in business language (Gherkin: Given/When/Then).
Scenario: Successful password reset
Given a user with email "[email protected]" exists
And the user has not reset their password in the last 24 hours
When the user requests a password reset link
Then an email is sent to "[email protected]" within 60 seconds
And the link expires after 1 hour
Best fit: APIs with complex business rules; features where the business logic is the source of truth; scenarios with multiple stakeholders who need to agree on behavior.
Not a good fit for: Low-level technical code (use TDD instead); scenarios where Gherkin would be artificially verbose.
When to use: When you need the entire team — developer, tester, and business analyst — to agree on behavior before development begins.
Three Amigos: Before writing any code, three roles collaborate:
Together they write Gherkin scenarios that become the acceptance criteria and the test suite simultaneously.
Key distinction from BDD: ATDD is a process (collaboration before development); BDD is a format (Gherkin syntax). You can do BDD without ATDD (writing scenarios after the fact) or ATDD without Gherkin (using plain English acceptance criteria).
Use contract testing when you have microservices with separate deployment cycles. If services are always deployed together, you don't need contract tests. If a service can be deployed independently, you need to know its contracts are satisfied before deployment.
The problem contract testing solves: Service A consumes Service B's API. Service B adds a new required field. Service A deploys without knowing. Production breaks.
CONSUMER SIDE PROVIDER SIDE
───────────── ─────────────
1. Write interaction test 4. Provider downloads pacts
(expected request + response) from Pact Broker
↓ ↓
2. Pact generates contract 5. Provider verifier runs
(.json pact file) against real provider code
↓ ↓
3. Publish to Pact Broker 6. Publish verification results
↓ ↓
7. can-i-deploy checks compatibility
before any deployment to production
Consumer-driven contracts mean consumers set the rules. The consumer defines what it needs from the provider. The provider must satisfy those needs. This inverts the traditional approach where providers define APIs and consumers adapt.
Pact Broker is required for multi-team use. The broker stores contracts, verification results, and enables the can-i-deploy gate.
can-i-deploy is the deployment gate:
# This command asks: "Can OrderService v1.2.3 be deployed to production?"
# It checks all consumer contracts are verified for this version
pact-broker can-i-deploy \
--pacticipant OrderService \
--version 1.2.3 \
--to-environment production
# Returns: 0 (can deploy) or 1 (cannot deploy, contract violations exist)
Contract tests verify compatibility, not correctness. You still need integration and E2E tests.
Property-based testing (Hypothesis) finds edge cases that example-based tests miss. Use it for:
| Good fit | Poor fit |
|---|---|
| Pure functions (no side effects) | UI flows |
| Data transformations | Performance testing |
| Serialization / deserialization | Complex setup/teardown scenarios |
| Parsers and validators | Anything requiring real external services |
| Mathematical operations | |
| State machines | |
| Round-trip properties (encode → decode = original) |
Shrinking is what makes property-based testing practical: the actual failing input might be 10,000 characters, but Hypothesis shrinks it to "" or "a" — the root cause.
# Round-trip: encode then decode returns original
@given(st.text())
def test_json_round_trip(s):
assert json.loads(json.dumps({"value": s}))["value"] == s
# Invariant: sorted list is always ordered
@given(st.lists(st.integers()))
def test_sort_preserves_all_elements(lst):
sorted_lst = sorted(lst)
assert len(sorted_lst) == len(lst)
assert sorted(sorted_lst) == sorted_lst
# Commutativity: order doesn't matter
@given(st.integers(), st.integers())
def test_addition_is_commutative(a, b):
assert a + b == b + a
# No crash guarantee: valid inputs should never raise unexpected exceptions
@given(st.text(min_size=1, max_size=255))
def test_username_validation_never_crashes(username):
try:
result = validate_username(username)
assert isinstance(result, bool) # always returns a bool
except ValueError:
pass # ValueError is acceptable for invalid inputs
# Any other exception is a bug
Mutation testing introduces code mutations (changes to operators, conditions, return values) and verifies your tests catch them. It answers the question: "Do my tests actually detect bugs, or do they just run code?"
Mutation score = killed mutants / total non-equivalent mutants × 100
A mutation score below 60% means your tests have significant gaps — regardless of coverage percentage. High coverage + low mutation score = tests are checking behavior happened, not that it happened correctly.
Mutation testing is too slow for CI gates on large codebases. Use it as:
Don't gate PRs on mutation score (too slow). Do track mutation scores in your quality metrics dashboard and investigate declining trends.
Understanding the distinction prevents over-mocking (London school trap) and under-isolation (integration test creep).
| Double | What It Is | When to Use |
|---|---|---|
| Stub | Returns canned responses; doesn't verify calls | Providing test data; avoiding real I/O |
| Mock | Verifies calls were made; has expected behavior | Verifying interactions with collaborators |
| Spy | Wraps real object; records calls for later assertion | Verifying calls on a real object you can't replace |
| Fake | Working implementation simplified for testing | In-memory database; fake email service |
| Dummy | Placeholder that's never called | Satisfying required parameters that aren't used |
Is this crossing an I/O boundary? (network, disk, external service)
→ YES: Use a stub or fake. Always.
→ NO: Do you need to verify the interaction happened?
→ YES: Use a mock (carefully)
→ NO: Use the real object
Don't mock what you don't own. If you're mocking requests.get() directly, you're coupling your tests to an implementation detail. Instead: wrap the HTTP call in your own HttpClient class and mock that.
Fake vs. Mock for databases:
Bad: Test that UserService.__init__ calls Repository.__init__ with specific parameters
Good: Test that creating a user through UserService.create_user() results in a user that can be retrieved
Tests should survive refactoring. If renaming an internal variable breaks a test, the test is testing the wrong thing.
Signs: Tests break when unrelated code changes; tests depend on specific database row ordering; tests use hardcoded timestamps
Fix: Use domain-specific test data builders; avoid ordering dependencies; inject clocks and use freezegun for time-sensitive tests
Signs: Developers run tests "occasionally"; CI pipeline takes > 30 minutes; "I'll run tests later"
Fix:
pytest-xdist -n autopytest -m "not slow" for local development feedback loopSigns: Tests pass in isolation, fail in sequence; tests leave data in databases; "works on my machine"
Fix:
100% coverage target: Causes trivial tests that don't verify behavior to be written. The coverage metric becomes gamed. Stop when you hit 100%, not when you've verified all behavior.
Counting untested code as passing: Missing a test for a critical path is not "acceptable coverage" — it's a risk.
Fix: Set a minimum floor (80% overall, 100% for critical paths). Track coverage delta on PRs to prevent regression. Focus investment on behavior verification, not percentage maximization.
| Approach | When to Use | Example |
|---|---|---|
| Hardcoded values | Simple, obvious test data | user = User(name="Alice") |
| Factory functions | Reusable, customizable test data | user_factory(role="admin") |
| factory_boy | Complex objects with relationships | UserFactory(orders__count=3) |
| Fixtures (pytest) | Shared infrastructure (DB session, HTTP client) | @pytest.fixture(scope="session") |
| testcontainers | Real service dependencies | PostgreSQL, Redis, Kafka, Azurite |
# factories.py
import factory
from faker import Faker
from myapp.models import User, Order
fake = Faker()
class UserFactory(factory.Factory):
class Meta:
model = User
id = factory.LazyFunction(lambda: str(uuid4()))
email = factory.LazyFunction(fake.email)
name = factory.LazyFunction(fake.name)
role = "user"
class Params:
admin = factory.Trait(role="admin")
# Usage
user = UserFactory() # default user
admin = UserFactory(admin=True) # admin user
custom = UserFactory(email="[email protected]") # specific email
Never share mutable test data between tests. Each test creates its own data. Tests that share data are tests that depend on execution order — the definition of a fragile test suite.
Performance testing is not a single test type — it is a progression:
| Test Type | Purpose | When to Run |
|---|---|---|
| Baseline | Establish normal performance under expected load | Before any load testing |
| Load | Verify system performs under expected traffic | Every release for critical services |
| Stress | Find the breaking point | Quarterly for capacity planning |
| Soak/Endurance | Find memory leaks, resource exhaustion | Before major releases |
| Spike | Verify recovery from sudden traffic increases | Before marketing campaigns |
Locust for Python load testing:
from locust import HttpUser, task, between
class APIUser(HttpUser):
wait_time = between(0.5, 2.0)
@task(3) # runs 3x more often than weight 1 tasks
def get_products(self):
self.client.get("/api/products?page=1&size=20")
@task(1)
def create_order(self):
self.client.post("/api/orders", json={
"productId": "PROD-123",
"quantity": 1
})
Defining pass/fail criteria (required for CI integration):
# locust pass/fail criteria
--headless
--users 100
--spawn-rate 10
--run-time 60s
--html report.html
# Exit codes: 0=pass, 1=fail (if Locust thresholds exceeded)
# Configure in locust.conf: stop-on-fail, exit-code-on-error
Security testing should be distributed across all layers, not isolated to a pentest phase:
| Layer | Security Test Type | Tool | Timing |
|---|---|---|---|
| Static analysis | SAST (source code vulnerabilities) | Bandit, Semgrep | Every PR |
| Unit | Input validation logic | pytest with adversarial inputs | Every PR |
| Integration | Auth enforcement, SQL injection | pytest with malicious payloads | Every PR |
| Contract | API security headers, auth requirements | Pact with security scenarios | Every PR |
| E2E | DAST (runtime vulnerability scanning) | OWASP ZAP baseline | Every build |
| Pentest | Manual exploitation, business logic | Internal quarterly, external annually | Scheduled |
OWASP ZAP baseline scan in CI:
- task: CmdLine@2
displayName: 'OWASP ZAP Baseline Scan'
inputs:
script: |
docker run -t owasp/zap2docker-stable zap-baseline.py \
-t https://staging.myapp.com \
-J zap-report.json \
-x zap-report.xml
The baseline scan catches common vulnerabilities (missing security headers, information disclosure) automatically. It will not catch business logic vulnerabilities or complex authentication bypass — that requires human testing.
Use these questions to diagnose an existing test suite before recommending improvements:
Coverage and Distribution
Speed and Reliability
Confidence
Maintenance
Integration and Contract
For communicating test strategy to stakeholders:
TEST STRATEGY: [System Name]
ARCHITECTURE TYPE: [Monolith / API / Microservices / Frontend]
RECOMMENDED SHAPE: [Pyramid / Trophy / Honeycomb]
TEST DISTRIBUTION TARGET:
Unit tests: [X%] — [rationale]
Integration tests: [X%] — [rationale]
Contract tests: [X%] — [rationale, if microservices]
E2E tests: [X%] — [rationale]
QUALITY GATES:
Coverage threshold: [80%] overall, [100%] for [list critical paths]
Flake rate: < 2% per test
Full suite runtime: < [30 min]
SAST scan: 0 Critical/High findings
RISK COVERAGE (Swiss Cheese):
✓ Static analysis (Ruff, mypy, Bandit)
✓ Unit tests
✓ Integration tests (testcontainers)
○ Contract tests [MISSING — see Q3 OKR]
✓ E2E tests (smoke tests for critical journeys)
✓ Production monitoring (Application Insights alerts)
CURRENT STATE:
Coverage: [X%] | Flake rate: [X%] | Suite runtime: [Xm]
Top risk: [e.g., no contract tests for InventoryService boundary]
IMPROVEMENT PRIORITY:
1. [Highest-impact gap]
2. [Second priority]
3. [Third priority]
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
2 plugins ship this exact skill · first indexed Aug 12, 2026
3 skills in this plugin
/debugging-and-observabilityComprehensive practitioner guide to debugging, logging, error handling, and production observability (2026): Agans' nine rules, delta debugging, reproducibility imperative, correlation/trace IDs, OpenTelemetry (CNCF graduated May 11 2026), structured logging (slog/Pino/Serilog/structlog), four observability signals (logs/metrics/traces/profiling), eBPF zero-instrumentation telemetry, SLO-based burn-rate alerting, resilience patterns (retries with jitter, circuit breakers, bulkheads), distributed debugging, AI debugging limitations (OpenRCA 11–36%), and language-specific patterns for Python, TypeScript/JavaScript, and Go./python-quality-testingUse when writing Python tests, setting up pytest, implementing TDD in Python, using Hypothesis for property-based testing, setting up mutation testing, configuring Ruff/mypy/Black, implementing contract testing with Pact, or building Python quality pipelines on Azure. Triggers on any Python testing or quality tooling question, including pytest fixtures, parametrize, conftest, coverage thresholds, testcontainers, Azurite, Cosmos DB emulator, or Azure DevOps pipeline YAML for Python.Other plugins' skills for the same job
npx claudepluginhub the-vibey-project/vibey --plugin quality-engineering