testing-strategies — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited testing-strategies (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Build comprehensive, effective test suites by strategically selecting and implementing the right testing approaches across unit, integration, E2E, and contract testing levels.
This skill provides strategic frameworks for:
Testing is foundational to reliable software. With microservices architectures and continuous delivery becoming standard in 2025, strategic testing across multiple levels is more critical than ever.
Invoke this skill when:
The testing pyramid guides test distribution for optimal speed and confidence:
/\
/ \ E2E Tests (10%)
/----\ - Slow but comprehensive
/ \ - Full stack validation
/--------\
/ \ Integration Tests (20-30%)
/ \ - Moderate speed
/--------------\ - Component interactions
/ \
/------------------\ Unit Tests (60-70%)
- Fast feedback
- Isolated unitsKey Principle: More unit tests (fast, isolated), fewer E2E tests (slow, comprehensive). Integration tests bridge the gap.
Microservices Adjustment:
Cloud-Native Patterns:
For detailed pyramid guidance, see references/testing-pyramid.md.
START: Need to test [feature]
Q1: Does this involve multiple systems/services?
├─ YES → Q2
└─ NO → Q3
Q2: Is this a critical user-facing workflow?
├─ YES → E2E Test (complete user journey)
└─ NO → Integration or Contract Test
Q3: Does this interact with external dependencies (DB, API, filesystem)?
├─ YES → Integration Test (real DB, mocked API)
└─ NO → Q4
Q4: Is this pure business logic or a pure function?
├─ YES → Unit Test (fast, isolated)
└─ NO → Component or Integration Test| Feature | Test Type | Rationale |
|---|---|---|
calculateTotal(items) | Unit | Pure function, no dependencies |
POST /api/users endpoint | Integration | Tests API + database interaction |
| User registration flow (form → API → redirect) | E2E | Critical user journey, full stack |
| Microservice A → B communication | Contract | Service interface validation |
formatCurrency(amount, locale) | Unit + Property | Pure logic, many edge cases |
| Form validation logic | Unit | Isolated business rules |
| File upload to S3 | Integration | External service interaction |
For comprehensive decision frameworks, see references/decision-tree.md.
Purpose: Validate small, isolated units of code (functions, methods, components)
Characteristics:
When to Use:
Recommended Tools:
For detailed patterns, see references/unit-testing-patterns.md.
Purpose: Validate interactions between components, modules, or services
Characteristics:
When to Use:
Recommended Tools:
For detailed patterns, see references/integration-testing-patterns.md.
Purpose: Validate complete user workflows across the entire application stack
Characteristics:
When to Use:
Best Practices:
Recommended Tools:
For detailed patterns, see references/e2e-testing-patterns.md.
Purpose: Validate service interfaces and API contracts without full integration
When to Use:
Recommended Tool: Pact (pact.io) - supports TypeScript, Python, Go, Rust
For detailed patterns, see references/contract-testing.md.
Fixtures (Static Data):
Factories (Generated Data):
Property-Based Testing (Random Data):
Recommended Combination:
Property-Based Testing Tools:
For detailed strategies, see references/test-data-strategies.md.
| Dependency | Unit Test | Integration Test | E2E Test |
|---|---|---|---|
| Database | Mock (in-memory) | Real (test DB, Docker) | Real (staging DB) |
| External API | Mock (MSW, nock) | Mock (MSW, VCR) | Real (or staging) |
| Filesystem | Mock (in-memory FS) | Real (temp directory) | Real |
| Time/Date | Mock (freezeTime) | Mock (if deterministic) | Real (usually) |
| Environment Variables | Mock (setEnv) | Mock (test config) | Real (test env) |
| Internal Services | Mock (stub) | Real (or container) | Real |
Guiding Principles:
For detailed mocking patterns, see references/mocking-strategies.md.
Unit Testing with Vitest:
import { describe, test, expect } from 'vitest'
test('calculates total with tax', () => {
const items = [{ price: 10, quantity: 2 }]
expect(calculateTotal(items, 0.1)).toBe(22)
})Integration Testing with MSW:
import { setupServer } from 'msw/node'
import { http, HttpResponse } from 'msw'
const server = setupServer(
http.get('/api/user/:id', ({ params }) => {
return HttpResponse.json({ id: params.id, name: 'Test User' })
})
)E2E Testing with Playwright:
import { test, expect } from '@playwright/test'
test('user can checkout', async ({ page }) => {
await page.goto('https://example.com')
await page.getByRole('button', { name: 'Add to Cart' }).click()
await expect(page.getByText('1 item in cart')).toBeVisible()
})See examples/typescript/ for complete working examples.
Unit Testing with pytest:
def test_calculate_total_with_tax():
items = [{"price": 10, "quantity": 2}]
assert calculate_total(items, tax_rate=0.1) == 22Property-Based Testing with hypothesis:
from hypothesis import given, strategies as st
@given(st.lists(st.integers()))
def test_reverse_reverse_is_identity(lst):
assert reverse(reverse(lst)) == lstSee examples/python/ for complete working examples.
See examples/go/ and examples/rust/ for complete working examples in these languages.
Recommended Targets:
Anti-Pattern: Aiming for 100% coverage leads to testing trivial code and false confidence.
Coverage Tools:
Mutation testing introduces bugs and verifies tests catch them.
Tools:
For detailed coverage strategies, see references/coverage-strategies.md.
Stage 1: Pre-Commit (< 30 seconds)
Stage 2: On Commit (< 2 minutes)
Stage 3: Pull Request (< 5 minutes)
Stage 4: Pre-Merge (< 10 minutes)
Speed Up Test Runs:
vitest --threadsplaywright test --workers=4pytest -n auto (requires pytest-xdist)go test -parallel 4Problem: Too many E2E tests, too few unit tests Result: Slow test suites, flaky tests, long feedback loops Solution: Rebalance toward more unit tests, fewer E2E tests
Problem: Tests coupled to internal structure, not behavior Solution: Test behavior (inputs → outputs), not implementation
Problem: Mocking everything defeats purpose of integration tests Solution: Use real databases (ephemeral), mock only external APIs
Problem: Tests fail intermittently due to timing issues Solutions:
sleep(1000))For form testing: See building-forms skill for form-specific validation and submission testing patterns.
For API testing: See api-patterns skill for REST/GraphQL endpoint testing and contract validation.
For CI/CD pipelines: See building-ci-pipelines skill for test automation, parallel execution, and coverage reporting.
For data visualization testing: See visualizing-data skill for snapshot testing chart configurations and visual regression testing.
For deeper exploration of specific topics:
Complete, runnable code examples are available in the examples/ directory:
All examples include dependencies, usage instructions, and error handling.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.