Get more value from your tests by writing them first with TDD

Writing tests last

Writing tests the usual way (after you’ve written and tried the app by hand) often doesn’t feel like a good use of your time. After all, how often do you find a bug the first time you write a test? If the tests don’t find bugs, what is their value?

You know as a good developer that you should have tests to help ensure the next person that touches your code is doesn’t break it. But that won’t happen until some undermined time in the future.

non tdd test value

Is there a way you can get more value from your tests? Absolutely.

Writing tests first

What if you switched the order and wrote your tests before you wrote your production code? Then you could use those tests to help you during the whole time you were writing the code. You don’t have to wait for hypothetical future code changes to for your tests to be useful. The tests immediately have value!

tdd test value

By having those tests ready to run during your development time, you’ll only need to do very minimal (if any) manual testing to verify your code works. Running your automated tests that cover your work is much faster and easier than doing manual testing to verify your work. And once all the tests pass that cover the feature you’re coding, you know you’re done with that feature and you can move on to the next task, letting you get more work done more quickly.

By writing your tests first, you will get more value out of them. And if you aren’t careful, you may start enjoying writing tests!