Unit testing functions
Fixing bugs in code is expensive. The earlier that a bug is discovered in the development process, the less expensive it will be to fix.
Unit testing is a good way to find bugs early in the development process. Some developers even follow the principle that programmers should create unit tests before they write code, and this is called Test-Driven Development (TDD).
More Information: You can learn more about TDD at the following link: https://en.wikipedia.org/wiki/Test-driven_development
Microsoft has a proprietary unit testing framework known as MS Test; however, we will use the third-party framework xUnit.net.
Creating a class library that needs testing
First, we will create a function that needs testing.
- Inside the
Chapter04
folder, create two subfolders namedCalculatorLib
andCalculatorLibUnitTests
, and add them each to the workspace. - Navigate to Terminal | New Terminal and select
CalculatorLib
. - Enter the...