Why Unit Test: How To Write Solid Code

Опубликовано: 01 Январь 1970
на канале: Kodaps Academy
475
27

There is a saying among developers: To err is human… but to really mess things up, you need a computer. That saying underlines the problem we have, as developers. Our code is fragile. It breaks. How do we solve that problem?

Hi, I’m David, and In this video we’ll be exploring together how we can make sure that our code doesn’t… mess everything thing up. And along the way we’ll see that the solution to this problem has added benefits, including one you probably hadn’t thought of.

But first, why do we have this problem? Why is our code fragile?

First, it’s impossible to keep track of all the information we need. The needs, requirements, and technology… evolve. The systems we deal with have complex interactions. It’s impossible for your brain to hold all the rules and behaviors that are supposed to happen. All the specifications. All the use cases. Everything the code is supposed to do.

How can we solve that?

Before we go into that… the situation is (in fact) even worse than it seems.

Because as developers, some of the systems we work on deal with vital resources. We could be making sure people get paid on time, or receive their Christmas gifts… or managing inventory that means life or death for patients in hospitals, or coding self-driving cars.

Obviously, (and thankfully) not everything we do has that much importance.
But some of it does. And even if all we are doing is making someone’s life easier, with a tool, or more fun, with a game… Well, that’s important too. People depend on our code.

How can we ensure our code doesn’t mess everything up at the wrong time?

Let’s be frank: it’s not humanly possible. There is too much information to hold in our brains. It’s too complex, it’s beyond our capacity. But thankfully, I have good news.

All this is within a computer’s capacity!

Here is what we can do: write additional code, and have that code test our code. And that, ladies and gentlemen, is what automated testing is all about. It’s about writing more code, to automatically test that your code is doing what it should.

And what are the different types of test? And what are the added benefits? But first : How does that work in practice?

#testing #coding #development