Manage episode 208736672 series 1435515
Visit Agile Thoughts and register to receive free development, analysis, or leadership and management materials and learn to excel at developing software. I’ll also send information on my low cost email courses you can take via the internet.
012 AN EXAMPLE OF DOING TDD
TDD is a clever process. By writing your test before the code, you end up growing your test with the code.
So let’s throw away that untested code from last episode and start over. The first developer writes a test program to check that the program she will write, shows the word “aware.” The test program won’t execute until there exists a stub of the program—essentially an interface around an empty body that does nothing, so after a she writes the test she creates the stub, then executes the test. She observes the test program reports a failure.
Great! The automated test is now the nagging shrew “driving” the programmer to make it happy. The developer adds to the program the ability to produce the word “aware” and runs the test program. The test program communicates with the wanted program and declares that it passes the test. The developer publishes the program.
Later, another developer is asked to add the colon, which she does by adding a test that reports a failure. She then makes the wanted program have the colon. When she runs the test program, she executes all the tests and both pass. She publishes the code. The third developer doing the “ness” work doesn’t make the mistake of losing the colon because, as there is a test that explicitly checks for the colon, she doesn’t need to guess the intent of the programmers before her.
With Test Driven Development, before you can add more code to your program, your first order of business is to figure out how to test what you want to add. It’s a virtuous cycle!
Next episode we’ll discuss Developer Intent and how that could have made collaborative operations such as producing Bibles get to market faster and with fewer defects.
This podcast frequently uses sound effects from http://FreeSound.org and specifically used samples available via the Creative Commons license from the following members:
jay_rope, fennelliott, Timbre.
17 episodes available. A new episode about every 35 days averaging 4 mins duration .