Description
Description
This two-day, instructor-led course teaches developers how to write, organize, and run high-quality unit tests using Visual Studio 2022 and popular .NET testing frameworks such as MSTest, NUnit, and xUnit. It also introduces powerful practices like Test-Driven Development (TDD) and explores how modern unit testing integrates with the development lifecycle for cleaner, more reliable code.
The course is rich in hands-on labs, real-world use cases, and productivity tools like Live Unit Testing, IntelliTest, and third-party libraries such as moq and NCrunch. Participants will learn practical strategies for testing hard-to-reach code, isolating dependencies, and ensuring coverage without falling into the trap of treating coverage as a goal.
Training Objectives
- Learn to write effective
- maintainable unit tests with MSTest
- NUnit
- and xUnit
- Understand the principles and value of Test-Driven Development (TDD)
- Gain hands-on experience with Visual Studio tools: Test Explorer
- Live Unit Testing
- CodeLens
- and IntelliTest
- Refactor legacy code safely using test scaffolding
- Test “difficult” code using mocking frameworks and Microsoft Fakes
- Manage and organize large test suites with grouping
- filtering
- and playlists
- Understand best practices for code coverage
- parameterized testing
- and exception handling
- Practice writing clean
- well-structured tests that cover edge cases and boundary conditions
Course Outline
- Module 1: Unit Testing in .NET<br />
- What unit tests are—and are not<
- Why unit tests matter in modern development<
- Overview of .NET testing frameworks: MSTest, NUnit, xUnit<
- Writing and running your first unit tests<
- Understanding the 3A pattern: Arrange, Act, Assert<
- Module 2: Unit Testing in Visual Studio<br />
- Creating test projects in Visual Studio<
- Using Test Explorer and other testing tools<
- Grouping, filtering, and organizing tests<
- Running and managing test results<
- Setting up continuous testing and .runsettings files<
- Module 3: Test-Driven Development (TDD)<br />
- The TDD cycle: Red, Green, Refactor<
- Business benefits and practical applications of TDD<
- Writing tests before code<
- Refactoring and working with legacy code<
- Leveraging CodeLens for insight<
- Module 4: Writing High-Quality Unit Tests<br />
- Beyond the happy path: testing sad and evil paths<
- Right-BICEP framework for robust testing<
- Exception handling in unit tests<
- Naming conventions and test organization strategies<
- Maintaining test readability and maintainability<
- Module 5: Leveraging Visual Studio for Advanced Testing<br />
- Analyzing code coverage: what it is and isn’t<
- Writing parameterized tests with DataRow, DynamicData, and DataSource<
- Live Unit Testing in Visual Studio<
- Using NCrunch for concurrent testing and performance feedback<
- Module 6: Testing Difficult Code<br />
- Understanding test doubles: dummies, fakes, stubs, and mocks<
- Isolating code under test from runtime dependencies<
- Using Microsoft Fakes (stubs and shims)<
- Comparing and using mocking frameworks: moq, NSubstitute, etc.<
- Debugging and profiling test code<
- Generating unit tests with IntelliTest<
- Tools Covered<br />
- Visual Studio 2022<
- MSTest, NUnit, xUnit<
- Microsoft Fakes<
- moq (and other mocking libraries)<
- NCrunch<
- IntelliTest<
- CodeLens<
- Test Explorer<
- .runsettings configuration




