WHAT'S IN THIS CHAPTER?
- Understanding some basic concepts of running unit tests
- Learning about the functionality of the Test pane in Visual Studio Code
As was mentioned at the very end of the last chapter, there is a common loop that software developers go through. The edit, compile, test, debug flow is at the heart of what coders do. Most of the book to this point has talked about three of those four steps: editing code, compiling and building the project artifacts, and debugging the application. This leaves us with testing, the topic of this chapter.
TESTING A UNIT
Before drilling down into the support that Visual Studio Code offers for unit testing, let's quickly describe what a unit test is. A unit, as we mean it here, is a specific piece of code that we would like to verify works as expected. It could be a method. It could be a class. Either of these works within the definition. The important part is that the functionality of the unit needs to be determined to be correct and, if there are problems, the developer needs to be notified. A unit test is a set of code whose purpose is to verify the correctness of the unit.
While it's a little cheesy, there is an acronym frequently associated with what makes a good unit test, TRIP:
Thorough: The set of tests that cover a unit should exercise all the key paths and scenarios. All branches should be tested, a requirement that frequently affects the design of both the methods and classes in your application.