askill
test-writer

test-writerSafety --Repository

Test design patterns, what to test, assertion strategies, mocking strategy, and common anti-patterns. Use when writing unit tests, integration tests, or end-to-end tests. Complements TDD workflow with concrete test design knowledge.

1 stars
1.2k downloads
Updated 2/6/2026

Package Files

Loading files...
SKILL.md

Test Writer

Decision Tree

Need to write a test → What kind?
    ├─ Testing a pure function → Unit test, no mocking needed
    ├─ Testing a class with dependencies → Unit test, mock dependencies
    ├─ Testing API endpoint → Integration test, real server + test DB
    ├─ Testing user workflow → E2E test (Playwright / platform integration test)
    └─ Testing UI appearance → Snapshot test

What to Test

Always TestSkip
Business logic / core algorithmsFramework internals
Edge cases (empty, null, boundary)Simple getters/setters
Error paths and error messagesThird-party library behavior
State transitionsPrivate methods (test via public API)
Integration points (API, DB)UI layout pixel-perfection
Security-sensitive paths (auth, validation)Generated code

Naming Convention

test_[unit]_[scenario]_[expected result]

# Examples:
test_login_with_valid_credentials_returns_token
test_login_with_expired_password_returns_403
test_cart_add_item_when_full_raises_limit_error

Assertion Best Practices

  • One logical assertion per test - Test one behavior, not one assert statement
  • Assert on behavior, not implementation - Check return values, not internal state
  • Use specific assertions - assertEqual(x, 5) not assertTrue(x == 5)
  • Include failure messages - assertEqual(result, 5, "discount should be 5% for VIP")
  • Test exact error types - assertRaises(ValueError) not assertRaises(Exception)

Mocking Strategy

MockDon't Mock
External APIs / HTTP callsThe unit under test
Database (in unit tests)Simple value objects
File system / networkPure functions
Time / randomnessInternal collaborators (usually)
Third-party servicesEverything (over-mocking = brittle tests)

Anti-Patterns

Anti-PatternProblemFix
Testing implementation detailsBreaks on refactorTest behavior/output
Flaky tests ignoredErode trust in test suiteFix or delete immediately
Copy-paste test setupHard to maintainUse fixtures/factories
No assertion (test just "runs")Proves nothingAlways assert expected outcome
Testing too much in one testUnclear what failedOne behavior per test
Mocking everythingTests prove nothingOnly mock boundaries

Test Structure (Arrange-Act-Assert)

# Arrange - Set up inputs and expected outputs
user = create_user(role="admin")

# Act - Call the function under test
result = permissions.can_delete(user, resource)

# Assert - Verify the result
assert result is True

Coverage Targets

  • New code: 80%+ line coverage
  • Critical paths (auth, payments, data): 95%+
  • Don't chase 100%: Diminishing returns past 85% overall

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

AI review pending.

Metadata

Licenseunknown
Version-
Updated2/6/2026
PublisherBigPapiCB

Tags

apidatabasegithub-actionssecuritytesting