Freigeben über


First look at testing tools in Visual Studio

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Visual Studio testing tools can help you and your team develop and sustain high standards of code excellence.

Note

Unit testing is available in all editions of Visual Studio. Other testing tools, such as Live Unit Testing and IntelliTest, are only available in Visual Studio Enterprise edition. For more information about editions see Compare Visual Studio IDEs.

Test Explorer

The Test Explorer window helps developers create, manage, and run unit tests. You can use the Microsoft unit test framework or one of several third-party and open source frameworks.

Visual Studio Test Explorer

Visual Studio is also extensible and opens the door for third-party unit testing adapters such as NUnit and xUnit.net. In addition, the code clone capability goes hand-in-hand with delivering high-quality software by helping you identify blocks of semantically similar code that may be candidates for common bug fixes or refactoring.

Third-party test integration

Live Unit Testing

Live Unit Testing automatically runs unit tests in the background, and graphically displays code coverage and test results in the Visual Studio code editor.

Note

Live unit testing is available in Enterprise edition only and is only supported for .NET code.

IntelliTest

IntelliTest automatically generates unit tests and test data for your managed code. IntelliTest improves coverage and dramatically reduces the effort to create and maintain unit tests for new or existing code.

IntelliTest in action

Note

IntelliTest is available in Enterprise edition only. It is supported for C# code that targets the .NET Framework. .NET Core and .NET Standard are not currently supported.

Code coverage

Code coverage determines what proportion of your project's code is actually being tested by coded tests such as unit tests. To guard effectively against bugs, your tests should exercise or "cover" a large proportion of your code.

Note

Code coverage is available in Enterprise edition only.

Code coverage analysis can be applied to both managed and unmanaged (native) code.

Code coverage is an option when you run test methods using Test Explorer. The results table shows the percentage of the code that was run in each assembly, class, and method. In addition, the source editor shows you which code has been tested.

Microsoft Fakes

Microsoft Fakes help you isolate the code you're testing by replacing other parts of the application with stubs or shims.

Note

Microsoft Fakes are available in Enterprise edition only and is supported only for .NET code.