This project allows Visual Studio extension developers to write integration tests that run inside an experimental instance of Visual Studio.
- Extension development requires Visual Studio 2017 or newer. Version 15.7 or newer is recommended for the best Test Explorer experience.
- Extensions themselves must target one or more versions of Visual Studio from the following list:
- Visual Studio 2012
- Visual Studio 2013
- Visual Studio 2015
- Visual Studio 2017
- Visual Studio 2019
- Visual Studio 2022
- Extensions must be deployed via one or more VSIX packages.
- Test execution and debugging is only supported for versions of Visual Studio available on the same machine as the development IDE.
Visual Studio Version | Integration Testing Package |
---|---|
2022 | Microsoft.VisualStudio.Extensibility.Testing.Xunit |
2012 - 2019 | Microsoft.VisualStudio.Extensibility.Testing.Xunit.Legacy |
Add the following to AssemblyInfo.cs to enable the test framework:
using Xunit;
[assembly: TestFramework("Xunit.Harness.IdeTestFramework", "Microsoft.VisualStudio.Extensibility.Testing.Xunit")]
💡 By default, SDK projects automatically generate the required assembly attribute. Manual customization is only required if the default assembly attributes support has been disabled, or in cases where the automatic application of
TestFrameworkAttribute
is not desired.
To disable generation of TestFrameworkAttribute
(which will require manual addition similar to classic projects), add
the following to the project file:
<PropertyGroup>
<GenerateTestFrameworkAttribute>false</GenerateTestFrameworkAttribute>
</PropertyGroup>
Add the following to AssemblyInfo.cs to deploy extensions required for testing.
using Xunit.Harness;
[assembly: RequireExtension("Extension.File.Name.vsix")]
Test projects using a customized xUnit test framework cannot currently be discovered while tests are being written. The test discovery process that runs after a build completes will detect the required tests. Ensure this feature is enabled by the following steps:
- Open Tools → Options...
- Select the Test page on the left
- Ensure Additionally discover tests from built assemblies after builds is checked
Tests will be automatically discovered and Test Explorer updated after each successful build.
Apply the [IdeFact]
attribute to tests that need to run in the IDE. After building the project, the tests will
appear in Test Explorer where they can be launched for running and/or debugging directly.
Please see CONTRIBUTING.md for information about our Code of Conduct and contributing guidelines.