Snapshooter currently does not support MSTest V4.
MSTest V4 is the successor to MSTest V3 and is currently in preview. It is (among other things) binary-incompatible with MSTest V2 and V3, so adding support for it is a breaking change.
For example, consider a simple test like this:
using Snapshooter.MSTest;
namespace TestProject1;
[TestClass]
public sealed class Test1
{
[TestMethod]
public void TestMethod1()
{
"Hello World!".MatchSnapshot();
}
}
with *.csproj:
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="MSTest" Version="4.0.0-preview.25480.4" />
<PackageReference Include="Snapshooter.MSTest" Version="1.0.1" />
</ItemGroup>
When running this with, the following exception is thrown:
TestMethod1 (180ms): Error message: The test method "TestProject1.Test1.TestMethod1" threw an exception:
System.IO.FileNotFoundException: Could not load file or assembly
'Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Stack trace:
at Snapshooter.MSTest.MSTestSnapshotFullNameReader.IsTestMethodTestMethod(MemberInfo method)
at Snapshooter.MSTest.MSTestSnapshotFullNameReader.IsMSTestTest(MemberInfo method)
at Snapshooter.MSTest.MSTestSnapshotFullNameReader.ReadSnapshotFullName()
at Snapshooter.SnapshotFullNameResolver.ResolveSnapshotFullName(String snapshotName, String snapshotNameExtension)
at Snapshooter.Snapshooter.ResolveSnapshotFullName(String snapshotName, SnapshotNameExtension snapshotNameExtension)
at Snapshooter.MSTest.Snapshot.FullName()
at Snapshooter.MSTest.Snapshot.Match(Object currentResult, Func`2 matchOptions)
at Snapshooter.MSTest.SnapshotExtension.MatchSnapshot(Object currentResult, Func`2 matchOptions)
at TestProject1.Test1.TestMethod1() in D:\RiderProjects\TestProject1\TestProject1\Test1.cs:line 11
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Describe the solution you'd like
Snapshooter should support MSTest V4.
Additional context
MSTest V4 also deprecates [DataTestMethod], which will require an additional breaking change in the snapshot name detection logic. However, that may be better tracked as a separate issue after basic support is provided.
Snapshooter currently does not support MSTest V4.
MSTest V4 is the successor to MSTest V3 and is currently in preview. It is (among other things) binary-incompatible with MSTest V2 and V3, so adding support for it is a breaking change.
For example, consider a simple test like this:
with *.csproj:
When running this with, the following exception is thrown:
Describe the solution you'd like
Snapshooter should support MSTest V4.
Additional context
MSTest V4 also deprecates
[DataTestMethod], which will require an additional breaking change in the snapshot name detection logic. However, that may be better tracked as a separate issue after basic support is provided.