TDD (Test-Driven Development) is writing a failing test first, then making it pass and refactoring. It helps clarify requirements and design when logic is complex or risky.
TDD cycle:
It’s best for algorithms, business rules, or APIs with unclear requirements.
TDD for a parser:
Given "a,b", expect two tokens -> implement -> refactor