Why do we write tests?

For the next week, I'll be talking about testing and TDD in preparation for my free webinar on Wednesday.

I've heard overwhelmingly from bootcamp grads that they want to learn to write tests for their code. So last week, I posted a question to LinkedIn to ask why people think they should be writing tests. A lot people saw the post, a few people reacted, and only three people answered.

So I'm going to start off by answering the question of why, to set the foundation of everything else we're going to learn.

You write tests to create an unambiguous specification of correct behavior for the components of your application.

This is the core reason to write tests. Everything else is a second-order effect.

Implicit in the term specification is the idea that you'll write it before you write your application code. Defining the behavior of your code in a way that a computer can evaluate forces you to be specific and intentional in your decisions.

Stability, faster development feedback loops, modular architecture; they all come from being able to think through and articulate the correct behavior of your code.

More tomorrow.


Did you like this?

I send a daily email with tips and ideas like this one. Join the party!

Icon