Skip to content
ArceApps Logo ArceApps
ES

TDD in the Era of AI: Red, Green, Refactor, Prompt

⏱️ 2 min read
TDD in the Era of AI: Red, Green, Refactor, Prompt

🧪 Is TDD Dead?

Some say that with AI writing code, we don’t need tests. They are wrong. If AI writes the code, you must verify it. And the only way to verify logic at scale is with automated tests.

TDD (Test Driven Development) is the perfect safety net for AI-generated code.

🔄 The New Cycle: Red, Green, Prompt, Refactor

The classic cycle was:

  1. Red: Write a failing test.
  2. Green: Write minimum code to pass.
  3. Refactor: Clean up.

The AI-Enhanced Cycle is:

  1. Red (Human): You write the test (The Specification). This defines “Done”.
  2. Green (AI): You ask Copilot/Gemini: “Implement the function to pass this test.”
  3. Refactor (AI + Human): “Optimize this solution.”

📝 Example: Validation

Step 1: The Test (Human)

@Test
fun `should return error when password lacks uppercase`() {
    val validator = PasswordValidator()
    val result = validator.validate("password123")
    assert(result is ValidationResult.Error)
}

Step 2: The Prompt (Human) “Generate PasswordValidator that passes this test.”

Step 3: The Code (AI)

class PasswordValidator {
    fun validate(input: String): ValidationResult {
        if (!input.any { it.isUpperCase() }) {
            return ValidationResult.Error("Must contain uppercase")
        }
        return ValidationResult.Success
    }
}

🚀 Why this is faster

  • You don’t think about implementation details (“how do I check uppercase in regex?”).
  • You only think about Behavior and Edge Cases.
  • The AI guarantees the syntax is correct.
  • The Test guarantees the logic is correct.

🎯 Conclusion

Don’t let AI write code without a spec. The Test is the Spec. Write the test first, and you will become the Architect of the AI, not just its reviewer.

You might also be interested in

Asynchronous Pair Programming with Agents: Sentinel, Bolt, and Palette in Action
AI May 22, 2025

Asynchronous Pair Programming with Agents: Sentinel, Bolt, and Palette in Action

Real Android development cases where delegating to specialized agents beats any standard AI chat. Security, Performance, and UX.

Read more
agents.md: The New Standard for AI Development
AI December 29, 2025

agents.md: The New Standard for AI Development

Discover why agents.md has become the de facto standard for configuring AI agents and how to effectively implement it in Android projects.

Read more
AI Skills in Development: Powering Your Android Workflow
AI December 29, 2025

AI Skills in Development: Powering Your Android Workflow

Discover how AI Skills transform modern development, automating complex tasks and improving productivity in Android projects.

Read more