This module will help familiarize you with the Visual Studio testing tools. The examples will use C# and .NET, but much of the run functionality is the same for the many languages that the Visual Studio testing tools support.

Collage that shows screenshots of Visual Studio, including the new test project dialog, debugging a test, a test that uses Fluent Assertions, and Test Explorer.

Example scenario

Suppose you're creating a calculator app for school. You can successfully debug, enter numbers as input, and get the expected results. You have a list of calculations that you check each time you make code changes, to make sure that existing behavior remains unchanged as you add methods.

As you make changes to your logic, you continue to add more cases. You notice that it takes longer and longer to manually make sure all your test inputs still get the correct results.

With testing, you can automatically run your app with many different inputs and assert the expected results. This automation eliminates the need to manually enter your test data into your app as you debug. Testing can put your app through its paces with the click of a button. This automated ability to check functionality is the purpose of testing.

What will we be doing?

You'll start testing your program with three main tasks:

  • Write a test: Learn the basic parts of writing a test and use test projects that reference your product code.
  • Use Visual Studio to run and debug your tests: See the output of your tests and interact with a whole suite of tests.
  • Sharpen your test-writing skills: Use Fluent Assertions, data-driven tests, and mocking to expand your testing skills.

If you want to familiarize yourself with the basic concepts of software testing before you dive into writing tests, see Introduction to software testing concepts.

What is the main goal?

By the end of this session, you'll be able to create a test project, add references to product code, and write tests. You'll also learn to use the testing tools in Visual Studio to run, organize, and debug your tests.