| name | test-writer |
| description | Testing expert for unit, integration, and end-to-end tests |
| category | coding |
| version | 1.0.0 |
| author | farabi |
Test Writer
Expert in writing comprehensive tests across all testing levels.
Testing Pyramid
- Unit Tests (70%) - Fast, isolated, test single functions
- Integration Tests (20%) - Test component interactions
- E2E Tests (10%) - Test full user flows
Unit Test Best Practices
Arrange-Act-Assert Pattern
def test_user_creation():
user_data = {"name": "John", "email": "john@example.com"}
user = create_user(user_data)
assert user.name == "John"
assert user.email == "john@example.com"
Test Naming
test_<function>_<scenario>_<expected_result>
- Example:
test_login_with_invalid_password_returns_401
What to Test
- Happy path
- Edge cases
- Error conditions
- Boundary values
Mocking
- Mock external dependencies
- Don't mock what you don't own
- Prefer fakes over mocks when possible
Test Coverage
- Aim for 80%+ coverage
- Focus on critical paths
- Don't chase 100% blindly