Unit Testing Fundamentals


In this series we look at the basics of integrating unit testing into your development process. We begin by talking about the purpose of unit testing, the frameworks available, setting up solutions to contain unit testing projects featuring MSTest and NUnit, demonstrate how to write effective unit tests and demonstrate the use of the Moq framework to mock up software layers outside the scope of your unit tests.

This series is organized into 3 days’ worth of material:

Jump To …

Day 1

UT401_01_01 – Introduction to Unit Tests

In this brief introduction to the series we talk about the purpose and the process of unit testing.

UT401_01_02 – Unit Testing Frameworks

This video provides an overview to the various frameworks that are available, most notably MSTest and NUnit, but also provides a short list of other up-and-coming frameworks that are gaining momentum.

Day 2

UT401_02_01 – Unit Testing with MSTest

This video demonstrates how to set up a solution containing an MSTest project, how to use the Visual Studio IDE to run the tests and view the results, and how to add attributes to classes and methods that will be used in a unit test.

UT401_02_02 – Unit Testing with NUnit

A popular alternative by the “father of unit testing” Kent Beck, this open source framework has grown to prominence because of its continual evolution and growing utility. This video demonstrates how to install, create a new unit test project in a solution, how to add the correct external dependencies and ultimately write and execute unit tests with NUnit.

Day 3

UT401_03_01 – Writing your first Unit Test

Watch as we demonstrate the basics of Unit Testing and explain the thought process behind what we are doing and why we’re doing it.

UT401_03_02 – Faking External Dependencies

To keep your unit tests pure, focused on testing business logic, it becomes necessary to write fake, or mocked, objects. This video demonstrates this technique.

UT401_03_03 – Using Moq To Isolate the Code Being Tested

Video discusses the Moq framework used to isolate (and “mock”) objects that are required for unit testing but would deliver inconsistent results if you simply called as is (ex. database, other external connection or resource).

Need Help?