...

/

Why Do We Need Unit Tests?

Why Do We Need Unit Tests?

Learn about the importance of unit tests and how to write them.

We'll cover the following...

What is a unit test? You can skip to the next section if you’re already familiar with unit testing and test-driven development. If not, let’s say that unit tests are part of an engineering philosophy for efficient and agile development processes. They add a layer of automated testing to the application code before it is developed. The core concept is that a piece of code is accompanied by its test, both of which are built by the developer who works on that code. First, we design the test against the feature we want to deliver, checking the accuracy of its output and behavior. Since the feature is still not implemented, the test will fail, so the developer’s job is to build the feature to pass the test.

Unit testing is quite controversial. While test-driven development is beneficial for ensuring code quality and maintenance over time, not everybody undertakes unit testing in the daily development workflow. Why is that? ...