Skip to content

Latest commit

 

History

History
68 lines (47 loc) · 2.23 KB

File metadata and controls

68 lines (47 loc) · 2.23 KB

✅ Test-Driven Development (TDD) Group Activity

🎯 Objective

Students will practice describing and applying the three steps of the Test-Driven Development (TDD) cycle—Red, Green, and Refactor—by collaboratively planning and documenting their process for implementing a simple feature. This activity emphasizes understanding the purpose and flow of each step.


📝 Activity Instructions

🔹 Step 1: Understanding TDD

  1. In small groups, discuss the three steps of TDD: Red, Green, and Refactor.
  2. Each group should create a brief summary (1–2 sentences per step) explaining:
    • What happens during each phase.
    • Why it is important.

🔹 Step 2: Define the Feature

You are tasked with implementing a countVowels function that takes a string and returns the number of vowels (a, e, i, o, u) in the string.


🟥 Red Phase:

  • Write a failing test case for the countVowels function.
  • Describe:
    • What behavior you want to test.
    • Why the test is expected to fail initially.
  • Document expected output for various inputs:
    • "hello" → ?
    • "world" → ?
    • "" → ?
  • Explain:
    • Why starting with a failing test clarifies the function’s requirements.

🟩 Green Phase:

  • Brainstorm the simplest code that could make the test pass.
  • Document implementation ideas.
  • Focus only on meeting the test’s expectations.
  • Discuss:
    • Why it’s important to prioritize functionality over optimization in this step.

🟦 Refactor Phase:

  • Once the test passes:
    • Identify ways to improve the code’s readability, efficiency, or maintainability.
    • Propose specific refactoring steps.
    • Explain how those steps improve the implementation.
  • Reflect:
    • Why this step is critical for long-term project success.

🔹 Step 3: Present Your Work

Each group will present:

  • ✅ Their summaries of the Red, Green, and Refactor steps.
  • 🔴 The failing test they wrote during the Red phase and their reasoning.
  • 🟢 The minimal code they proposed during the Green phase and how it aligns with the test.
  • 🔵 The refactored code they designed and the benefits of their improvements.