Skip to main content

Instructor-led training

Test-Driven Development Using Visual Studio and MSTest, Rev. 6.0 Training in Mineola, New York

Private .NET training for organizations from Hartmann Software Group, delivered onsite in Mineola, New York or live online.

What you'll learn

An emerging software engineering paradigm is test-driven development, where tests are written early and testing is performed continuously during the development process. Problems are discovered early and corrected when they are found. This one-day course for developers explains the methodology of test-driven development and the use of Microsoft’s MSTest unit testing framework that comes with Visual Studio 2022, including the free Community version.
 
This course is designed to run on .NET 6.0, which is the latest version of .NET Core and is the main implementation of .NET going forward. .NET Core is a package-based implementation that is cross-platform, running on Mac and Linux besides Windows. .NET Framework 4.x continues to be supported. Object Innovations course 4106 covers unit testing on .NET 4.x.
 
The course is practical, with many example programs and tests written in C#, including a cumulative case study. The goal is to quickly bring you up to speed in doing unit testing in your .NET development projects. The student will receive a comprehensive set of materials, including course notes and all the programming examples.

Private Training for Teams

This course is offered as private, instructor-led training for organizations, onsite in Mineola, New York or live online. Dates, delivery format, and course content are arranged around your team's requirements.

This course is not currently scheduled as a public class for individual enrollment.

Request Group Training

Prerequisites

The student should have a basic knowledge of .NET Core and experience programming in C# with Visual Studio.

Course Outline

1. Test-Driven Development

  • What Is Test-Driven Development (TDD)?
  • Functional Tests / Customer Tests
  • Unit Tests / Programmer Tests
  • Test Automation
  • Simple Design
  • Refactoring
  • A Visual Studio Test Drive
  • TDD with Legacy Code

2. Visual Studio Unit Testing Fundamentals

  • Structure of Unit Tests
  • Unit Testing Framework
  • Assertions
  • Test Cases
  • Test Classes
  • Test Runners
  • Ignoring Tests
  • Initialization and Cleanup

3. More about MSTest Framework

  • Expected Exceptions
  • Custom Asserts
  • Playlists
  • Debugging Unit Tests
  • Command-line Test Runner
  • Refactoring

What makes test-driven development hard to master

The MSTest attributes can be learned in an afternoon. The harder part is the discipline: deciding what to test, writing the test before the code, and keeping the design simple as the code changes. The syllabus builds in that order.

  • Concepts first. Module 1 separates functional (customer) tests from unit (programmer) tests, then covers test automation, simple design and refactoring. A common misconception is that TDD just means "having unit tests." Tests written after the code tend to confirm what the code already does rather than drive its design.
  • Mechanics next. Module 2 covers the structure of a unit test, the unit testing framework, assertions, test cases and test classes, test runners, ignoring tests, and initialization and cleanup. The usual difficulties are weak assertions that cannot fail, tests that depend on each other's state, and ignored tests that are never revisited. Initialization and cleanup are what keep tests independent.
  • Refinement last. Module 3 adds expected exceptions, custom asserts, playlists, debugging unit tests and the command-line test runner. Refactoring appears again here, because the point is changing code while the tests stay green.
  • Legacy code. The syllabus includes TDD with legacy code. Code that was not written for testing is usually the hardest place to start, and it is where many teams need this material most.

Who it suits and what to take around it

This is a one-day, general-level course for developers who already write C# in Visual Studio and have basic .NET Core knowledge. It also suits training managers who want a team to share one testing vocabulary and structure. The course is designed to run on .NET 6, which Microsoft no longer supports (support ended November 2024), and uses Visual Studio 2022, including the free Community edition. It therefore fits organizations that build, maintain or migrate existing .NET 6 code. Organizations on newer .NET releases can ask for a private training proposal, since private courses can be tailored to the versions a team uses.

If C# or the .NET platform is still new to your team, C# and .NET Essentials is a natural step before this course. Afterward, ASP.NET Core MVC (VS2022) is a logical next step for teams that want to apply a test-first habit to web application code. Other options are in the .NET course listing.

Illustrative scenarios

The scenarios below are illustrations of how the course material can be applied. They are not descriptions of specific organizations or of the course's lab exercises.

  • Changing inherited code safely. A team might take over a C# service with no tests and need to modify it. The syllabus topics on TDD with legacy code, assertions and refactoring apply directly: pin down current behavior with tests, then restructure.
  • Standardizing team practice. A group might find that every developer lays out tests differently. Test classes, initialization and cleanup, ignoring tests and custom asserts give them common conventions. Playlists let them run a chosen subset of tests during development.
  • Running tests outside the IDE. A team might want the same tests to run from a script as well as inside Visual Studio. The command-line test runner and the debugging topics cover running tests from the command line and investigating failures when they occur.

AI coding assistants and unit testing

AI coding assistants can draft test classes, boilerplate setup and many simple assertions quickly. That is useful once you know the MSTest structure the course teaches.

Where they fall short:

  • Tests that mirror the code. An assistant given an implementation often writes tests that assert whatever it currently does, bugs included. That is the opposite of test-first design. Write or review the test from the requirement, not from the code.
  • Weak or misleading assertions. Generated tests may pass without checking anything meaningful. They may also handle expected exceptions in a way that hides the real failure.
  • Wrong or nonexistent APIs. Assistants mix syntax from other test frameworks or use members that do not exist in the MSTest or .NET version your project references. Compile and run everything.
  • Test independence. Generated tests can share state that initialization and cleanup should isolate.

To verify, make each new test fail first for the right reason, then pass. Change the code deliberately and confirm that a test fails. Run the suite from the command-line runner as well as the IDE, and review every assertion as you would production code.

Frequently asked questions

What level is this course, and what should I know first?

It is a general-level, one-day course. You should have basic .NET Core knowledge and experience programming in C# with Visual Studio. No prior unit testing experience is assumed.

What does the course cover?

Module 1 covers TDD concepts: functional versus unit tests, test automation, simple design, refactoring and TDD with legacy code. Module 2 covers MSTest fundamentals: test structure, assertions, test classes, runners, ignoring tests, and initialization and cleanup. Module 3 covers expected exceptions, custom asserts, playlists, debugging tests and the command-line test runner.

Which versions does the course use?

It is designed to run on .NET 6 with Visual Studio 2022, including the Community edition. Microsoft ended support for .NET 6 in November 2024, so the course suits teams maintaining or migrating existing .NET 6 code.

Can this be delivered privately for our team, onsite or online?

Yes. HSG delivers private training for organizations either onsite at your location or live online.

Can the content be customized to the .NET version we use?

Private courses can be tailored to the technology versions an organization uses, including current releases. You can describe your needs through a training proposal request.

Training locations

Test-Driven Development Using Visual Studio and MSTest, Rev. 6.0 training across the U.S. and beyond.

We provide private Test-Driven Development Using Visual Studio and MSTest, Rev. 6.0 training for organizations, onsite at your location or live online, throughout the United States and internationally.

View all Test-Driven Development Using Visual Studio and MSTest, Rev. 6.0 training locations

Train your team with HSG

Private, instructor-led training customized for your organization.

  • Onsite or live online delivery
  • Customized curriculum
  • For a single employee or an entire team
  • Flexible scheduling
  • Experienced instructors
Request Group Training

Questions? Call us at 303.377.6176
or email info@hartmannsoftware.com

Ready to train your team?

Let's customize this training for your organization.

Tell us about your employees, your goals, and your preferred schedule. We'll prepare a training proposal covering scope, delivery format, and pricing.