Unit tests give developers and testers a quick way to look for logic errors in the methods of classes in C#, Visual Basic, and C++ projects.
The unit test tools include:
Test Explorer—Run unit tests and see their results in Test Explorer. You can use any unit test framework, including a third-party framework, that has an adapter for Test Explorer.
Microsoft unit test framework for managed code—The Microsoft unit test framework for managed code is installed with Visual Studio and provides a framework for testing .NET code.
Microsoft Native Unit Test Framework—The Microsoft Native Unit Test Framework for C++ is installed as part of the Desktop development with C++ workload. It provides a framework for testing native code. Google Test, Boost.Test, and CTest frameworks are also included, and third-party adapters are available for additional test frameworks. For more information, see Write unit tests for C/C++.
Code coverage tools—You can determine the amount of product code that your unit tests exercise from one command in Test Explorer.
Microsoft Fakes isolation framework—The Microsoft Fakes isolation framework can create substitute classes and methods for production and system .NET code that create dependencies in the code under test. By implementing the fake delegates for a function, you control the behavior and output of the dependency object.
For .NET, you can also use IntelliTest to explore your code and generate test data and a suite of unit tests. For every statement in the code, a test input is generated that will execute that statement. A case analysis is performed for every conditional branch in the code.
Key tasks
Use the following articles to help with understanding and creating unit tests:
Tasks
Associated Topics
Tutorials: Learn about unit testing in Visual Studio from code examples.
Start testing your C# apps by using the testing tools in Visual Studio. Learn to write tests, use Test Explorer, create test suites, and apply the red, green, refactor pattern to write code.