Skip to content

Instantly share code, notes, and snippets.

@xpepper
Created November 20, 2021 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xpepper/5d78769ccb4eb67256bbcce02ec400cf to your computer and use it in GitHub Desktop.
Save xpepper/5d78769ccb4eb67256bbcce02ec400cf to your computer and use it in GitHub Desktop.
tags
TDD, testing

Another precious TDD exercise by Kent Beck

Let's say you interested in TDD but you just can't figure out how to write a test before you write the code. Here's a foolproof exercise that let's you experience the TDD workflow in spite of that block:

  1. Change the code as usual
  2. Write a test that only passes after the change
  3. Revert to before 1
  4. Type the test again (copy/paste is cheating & invalidates the warranty of the exercise)
  5. Make it compile by changing the code
  6. See it fail
  7. Change the code to make it pass

(original tweet: https://twitter.com/KentBeck/status/1421257650113634304?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment