Summary
Unit testing is a powerful way to verify that refactoring code does not introduce bugs, document your classes, and prevent bugs from occurring in the future.
Unit tests are code that tests other code. In .NET, project unit tests are usually performed with xUnit, NUnit, or MSTest. Each testing framework provides assertions that verify that code behaves correctly or fails a test if the actual value doesn’t match the expected value.
When we write unit tests, we typically structure our tests in the arrange/act/assert pattern, which sets up the thing being tested in the arrange step, does a single action in the act step, and verifies the correctness of the action’s result in the assert step.
In the next chapter, we’ll explore testing more with test-driven development.