Test First Programming

Published on Apr 20, 2019

Imagine if schools started with a test.

It could be a short test -- those that didn't score 100% would be given a weeks worth of study material. Those that pass that test keep taking tests until we find what they don't know.

Then, they just work on the things they failed.

There's a movement in programming that's like that. It's called Test Driven Development - or TDD.

You have to know what you're trying to accomplish. Then, you write a test, that when passing, shows that your code is doing only what it's supposed to.

You start the coding with a failing test. Why is it failing? Because you haven't done any programming yet. You've only gotten the test written.

Then, you have to code a feature that causes the run of the tests to return green lights. Green means go. You can now write more tests.

Write a test and start with it failing. Then, write code. Then run tests. There's a rhythm.

It's slow. It's methodical. Some might even claim that it takes the fun out of programming. But, are you programming to have fun? Or, are you programming to help a business stay alive and ensure the livelihood of all the employees?

Code doesn't last forever. But it should last long enough to get the business up and running.