Understand testing concepts
Unit tests are important to developers because they provide stability to software, confidence in their code, and the added benefit of documenting complex code. Unit tests provide numerous benefits, as we’ll see in this chapter.
In this section, we’ll review the concepts of testing and why each one is important to the stability and confidence in building a website.
Unit tests
The smallest test we can write to confirm the code functions as expected is a unit test. Unit tests are usually created to test small(-ish) methods, as well as to test multiple parameters sent into those methods and expect a certain result.
Identifying the types of unit tests to write is a simple process of finding conditions in a method and writing the relevant test for the behavior.
The following scenarios could justify unit tests throughout a method:
- Successful flow of a method (that is, the happy path)
- Failure of a method’s behavior...