Unit Testing
In the first part of this book, we covered the process of refactoring and some of the more common refactoring techniques. Now, it’s time for us to take a step back and remind ourselves of what refactoring is: refactoring is the process of changing the form or shape of the code without changing how it behaves.
In other words, we can make our code as clean and easy to maintain as we can, but if those changes introduce bugs, that’s not refactoring since refactoring is about changing the form of code without changing its behavior. To improve our code without introducing bugs, we need a safety net: unit testing.
In this chapter, we’ll explore unit tests and cover the following main topics:
- Understanding testing and unit tests
- Testing code with xUnit
- Refactoring unit tests
- Exploring other testing frameworks
- Adopting a testing mindset