Skip to main content

๐Ÿงช TDD Masterclass

Welcome to the TDD Masterclass! In this tutorial, you'll master the art of test-driven development using ECC's tdd-guide agent.

๐ŸŽฏ What is TDD?โ€‹

Test-Driven Development (TDD) is a software development methodology where you:

  1. ๐Ÿ”ด Red Phase - Write a failing test first
  2. ๐ŸŸข Green Phase - Write the minimum code to make it pass
  3. ๐Ÿ”ต Refactor Phase - Improve the code without changing behavior

This cycle ensures your code is always tested and you only build what's truly needed.

๐ŸŽฎ Try the TDD Commandsโ€‹

ECC Command Simulator
โฏ
Available Commands:

๐Ÿ“š The Red-Green-Refactor Cycleโ€‹

TDD Cycle: Building a Calculator

Step 1 of 4
1

๐Ÿ”ด Red: Write a Failing Test

First, write a test for functionality that doesn't exist yet. This test must fail.

// calculator.test.ts
import { add } from './calculator'

describe('Calculator', () => {
it('should add two numbers', () => {
  expect(add(2, 3)).toBe(5)
})
})
๐Ÿ’กRun the test now โ€” it should fail because add() doesn't exist yet!

๐Ÿ’ป Interactive Code Labโ€‹

Try writing your own TDD cycle! Start with a failing test:

TDD Lab: String Utilitiestypescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

๐ŸŽฏ TDD Best Practicesโ€‹

Do โœ…โ€‹

  • Write the smallest possible test first
  • Run tests frequently (after every change)
  • Commit after each green phase
  • Keep refactoring sessions short
  • Give tests descriptive names

Don't โŒโ€‹

  • Write implementation code before writing tests
  • Write multiple tests at once
  • Skip the refactoring phase
  • Test implementation details
  • Make tests too complex

โ“ Knowledge Checkโ€‹

โ“

In TDD, when should you write implementation code?

โ“

What should you do during the refactoring phase?

โ“

How long should a typical TDD cycle take?

๐ŸŽ‰ Congratulations!โ€‹

You've completed the TDD Masterclass! You learned:

  • โœ… The Red-Green-Refactor cycle
  • โœ… TDD best practices
  • โœ… How to use the /tdd command in ECC
  • โœ… Writing effective tests

๐Ÿ“– Next Stepsโ€‹

Check out the Interactive Tutorials section for more tutorials!