Introduction to Unit Testing and Test-Driven Development

מק"ט: #5452 | משך קורס: 24 שעות אק'

Unit testing is a way to prove that a functional piece of code indeed works. The goal of unit tests is to make sure (“assert”) that a specified condition executes against the code, and returns a predefined value. Over time, unit tests increase the code quality by creating high code coverage, and protecting against regression bugs.

Unit testing is a proven practice that helps achieve better code quality, better design and fewer bugs. During this course we will learn how to apply unit testing techniques, tools and methodologies in order to write better unit tests and achieve high code coverage.

*שדות חובה
PDF version

מטרות הקורס

  • Participants will learn about unit testing, its benefits, and how to apply it to existing code, learn about Test Driven Development, what mock objects are, and how and when to use them.

קהל יעד

  • .NET software developers

תנאי קדם

  • At least basic experience with .NET and C#


Day 1: - Unit Testing and TDD basics

  • Unit Testing 101
    • What is Unit Testing?
    • Benefits of Unit Testing
  • Writing basic unit tests
    • Setting up the environment
    • Writing our first unit tests with MSTest
      • Unit test structure
      • Naming conventions
      • AAA – Arrange Act Assert
      • Assert methods
      • Running tests with Visual Studio
    • Applying code coverage
    • Debugging tests
    • Writing tests with NUnit
      • Installing NUnit with NuGet
      • Running tests using ReSharper
    • Test Driven Development
      • What is Test Driven Development (TDD)
      • TDD vs Unit Testing

       This day includes hands-on labs on the above topics.


Day 2: - Unit Testing and TDD basics

  • Mock objects
    • Mocks, Fakes, Stubs, what are they?
    • Creating fakes with FakeItEasy
  • Unit testing existing (legacy) code
    • Challenges in testing existing code
    • Dependency-breaking techniques
    • Refactoring
    • Dependency injection
    • SOLID principles


Day 3: - Advanced topics

  • Maintainability of unit tests
    • Trusting unit tests
    • Reviewing unit tests
  • Testing “untestable” code
    • Isolation frameworks (Typemock Isolator, Microsoft Fakes)