VsixTesting allows you to easily test your Visual Studio Extensions.
The fastest way to get started is cloning the VsixTestingSamples repo and playing with it.
git clone https://github.com/josetr/VsixTestingSamples
TestProject.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="VsixTesting.Xunit" Version="0.1.49-beta" />
<!-- Optional package containing types used in this sample. -->
<PackageReference Include="VSSDK.Shell.11" Version="11.0.4" />
<!--
<ProjectReference Include="..\MyVsixProject\MyVsixProject.csproj" />
* VsixTesting contains an MSBuild target that scans all project references
and if they generate a .vsix package, it will copy them
to the output folder where the test assembly is located.
* VsixTesting will install all .vsix packages located next to the test assembly.
-->
</ItemGroup>
</Project>
TestClass.cs
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Xunit;
namespace Tests
{
public class TestClass
{
[VsFact]
void FactTest()
=> Assert.NotNull(Package.GetGlobalService(typeof(SVsWebBrowsingService)));
[VsTheory]
[InlineData(123)]
void TheoryTest(int n)
{
Assert.NotNull(Package.GetGlobalService(typeof(SVsWebBrowsingService)));
Assert.Equal(123, n);
}
}
}
All the settings are located in ITestSettings and are implemented by 3 attributes:
[VsTestSettings]
for classes/collections/assemblies[VsFact]
and[VsTheory]
for methods
Intellisense should be used to read the documentation for each property that can be set.
This repository is licensed with the Apache, Version 2.0 license.