DEV Community

Discussion on: Demonstrating TDD (Test-driven development) in Go

Collapse
 
quii profile image
Chris James

Refactoring means changing the code without changing behaviour.

Every example you gave of refactoring there changed the way the system worked (so not refactoring)

This might help quii.dev/The_Tests_Talk

Thread Thread
 
individualit profile image
Artur Neumann

hmm OK, I see. But for that I first need some code that does work and where the tests pass. After the tests pass with my (ugly, not optimized, not perfect) code I can start refactoring in the sense of changing code without changing the behaviour.
Where in TDD does that step come?

Thread Thread
 
quii profile image
Chris James • Edited

From the link I sent you above

  • Write a small test for a small amount of desired behaviour
  • Check the test fails with a clear error (red)
  • Write the minimal amount of code to make the test pass (green)
  • Refactor
  • Repeat.

If you want a more involved tutorial read github.com/quii/learn-go-with-tests