askill
tdd-testing

tdd-testingSafety 90Repository

Test-Driven Development methodology - RED, GREEN, REFACTOR cycle for all implementations

0 stars
1.2k downloads
Updated 2/5/2026

Package Files

Loading files...
SKILL.md

TDD Testing Skill

When to Use

  • Qualquer nova feature implementation
  • Bug fixes
  • Quando quer confidence que código funciona

TDD Cycle

Phase 1: RED - Write Failing Test

def test_user_creation():
    user_service = UserService(db, cache)
    user = user_service.create_user({
        "email": "test@example.com",
        "name": "Test User"
    })
    assert user.id is not None
    assert user.email == "test@example.com"

Phase 2: GREEN - Minimal Code to Pass

class UserService:
    async def create_user(self, data):
        user = User(**data)
        await self.db.add(user)
        return user

Phase 3: REFACTOR - Improve Without Breaking

class UserService:
    async def create_user(self, data):
        # Add validation
        self.validate_email(data["email"])
        
        # Add deduplication
        existing = await self.db.query(User).filter(
            User.email == data["email"]
        ).first()
        if existing:
            raise UserAlreadyExists()
        
        user = User(**data)
        await self.db.add(user)
        return user

Best Practices

  • 1 test → 1 feature
  • Keep tests focused and small
  • Test behavior, not implementation
  • Rerun tests frequently
  • Use fixtures for setup
  • Mock external dependencies

Tools Needed

  • unittest / pytest
  • Mock (for dependencies)
  • Faker (for test data)

Success Metrics

  • 80% code coverage

  • All tests pass
  • Tests run in <30 seconds
  • No flaky tests

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

80/100Analyzed 2/16/2026

A well-structured TDD skill with clear phase examples and best practices. Minor language inconsistency in trigger section, but overall solid reference content.

90
75
85
80
75

Metadata

Licenseunknown
Version-
Updated2/5/2026
Publisherils15

Tags

observabilitytesting