Why do we need unit tests?
In this section, we will learn what unit tests are and why they are useful in web development.
You can skip to the next section if you’re familiar with unit testing and test-driven development.
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...