Unit Testing with MSTest

Unit Testing with MSTest: Unit Testing: an overview, The MSTest Framework, Planning Unit Tests, Adding Test Classes, Writing Tests, Test-Driven Development.

Updated

  1. Unit Testing: an overview (Novice): What a unit test is, and why small classes with clear responsibilities can be tested on their own.
  2. The MSTest Framework (Apprentice): MSTest is Microsoft's testing framework for .NET. A test runner finds and runs your tests; a test class holds the tests for one class, in a test project of its own.
  3. Planning Unit Tests (Apprentice): Plan tests from the requirements, as a table of scenarios. Each scenario changes one thing, and the edges (at a limit, just inside it, just past it) find the most bugs.
  4. Adding Test Classes (Apprentice): Add an MSTest test project beside your app, give it a reference to the app, and add a test class for each class you test.
  5. Writing Tests (Apprentice): Name each test for its scenario, write it in three parts (Arrange, Act, Assert), check results with MSTest's Assert methods, and run one test for many inputs with DataRow.
  6. Test-Driven Development (Apprentice): In test-driven development you write a failing test first, then just enough code to pass it, then tidy up. Follow three short cycles that build a shipping calculator.