Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TDD: Test-Driven Development vs TAB-Driven Deve...

TDD: Test-Driven Development vs TAB-Driven Development (Devnexus)

The rise of AI-powered coding assistants is changing the way we approach code completion, often allowing us to accept suggestions with a simple press of the TAB key, significantly speeding up our workflow. These tools can even generate the necessary tests automatically.
In this context, is Test-Driven Development (TDD) becoming obsolete? Or does the practice of using tests to drive the design of our applications still hold substantial value in the age of AI? Let’s explore the evolving landscape of software development and look at the ongoing relevance of TDD in an AI-enhanced world.

Marit van Dijk

March 05, 2025
Tweet

More Decks by Marit van Dijk

Other Decks in Programming

Transcript

  1. Failing test Never trust a test you haven’t seen fail

    https://maritvandijk.com/use-testing-to-develop-better-software-faster/
  2. Accept partial suggestion macOS Windows / Linux Accept suggestion ⇥

    TAB Accept line ⌘→ END Accept word ⌥→ Ctrl+→
  3. Experiments: "TDD" with AI Assistant • Problem: FizzBuzz Tried different

    options: 1. Strict TDD (Red - Green - Refactor) 2. From Chat 3. Inline
  4. Experiment: Strict TDD • Problem: FizzBuzz 1. Write a test

    2. Ask for implementation 3. (Ask for) refactoring
  5. Experiment: Strict TDD • Problem: FizzBuzz 1. Write a test

    2. Ask for implementation 3. (Ask for) refactoring • Code completion kicks in for known problem.
  6. Experiment: From Chat • Problem: FizzBuzz 1. Ask AI Assistant

    about FizzBuzz 2. Ask for list of test cases
  7. Experiment: From Chat • Problem: FizzBuzz 1. Ask AI Assistant

    about FizzBuzz 2. Ask for list of test cases 3. Ask for tests in Java
  8. Experiment: From Chat • Problem: FizzBuzz 1. Ask AI Assistant

    about FizzBuzz 2. Ask for list of test cases 3. Ask for tests in Java
  9. Experiment: From Chat • Problem: FizzBuzz 1. Ask AI Assistant

    about FizzBuzz 2. Ask for list of test cases 3. Ask for tests in Java 4. Ask for implementation
  10. Experiment: Inline • Problem: FizzBuzz 1. Ask AI Assistant for

    test cases based on description 2. Ask to implement code that passes the tests
  11. TDD workflow with AI Assistant 1. Create test(s) 2. Ask

    AI Assistant Chat for code that passes the tests 3. Apply code from chat • Works with simple problems
  12. Experiment: Strict TDD • Problem: FizzBuzz • Strict TDD with

    Junie (Red/Green/Refactor): 1. Write a test 2. Ask Junie for implementation
  13. Experiment: Strict TDD • Problem: FizzBuzz • Junie creates the

    right code in the right location • Junie runs the tests & makes sure they pass
  14. TDD workflow with Junie 1. Create tests 2. Ask Junie

    for code that passes the tests 3. Repeat • Junie creates the right code in the right location • Junie runs the tests & makes sure they pass
  15. Experiment: Multiple files • Problem: Calculator • Junie creates the

    right files in the right location • Junie runs the tests & makes sure they pass
  16. Experiment: Build a small app test first • Ask Junie

    to generate implementation based on tests
  17. Experiment: Build a small app test first • We need

    an example • With tests • Let's reverse engineer!
  18. Example: Build a small app • Create Spring Boot project

    • Ask Junie to implement small app
  19. The code is tested • Junie added tests • Junie

    ran tests • How good are the tests?
  20. Example: Build a small app Let's use Junie to check

    up on Junie... 1. Add coverage with JaCoCo
  21. Example: Build a small app Let's use Junie to check

    up on Junie... 1. Add coverage with JaCoCo
  22. Example: Build a small app Let's use Junie to check

    up on Junie... 1. Add coverage with JaCoCo 2. Add mutation testing with Pitest
  23. Example: Build a small app Let's use Junie to check

    up on Junie... 1. Add coverage with JaCoCo 2. Add mutation testing with Pitest
  24. Experiment: Rebuild the small app • Remove implementation • Ask

    Junie to build app based on tests • Might get it right based on project history (?)
  25. Experiment: Rebuild the small app • Create empty project •

    Copy in the tests • Ask Junie to build app based on tests
  26. Experiment: Rebuild the small app • Tests don't always pass

    on first try • Junie makes fixes and tries again
  27. We need more than passing tests • Does the application

    start up? • What about security? • Performance? • Code quality? • Etc
  28. Can we do (strict) TDD with AI? • While it's

    possible to do (strict) TDD with AI • Generating code based on tests alone does not give (me) reliable results
  29. There is still value in • Defining requirements & guidelines

    • Fast feedback, like tests • Small(er) increments