SwissLife-OSS / snapshooter

Snapshooter is a snapshot testing tool for .NET Core and .NET Framework
https://swisslife-oss.github.io/snapshooter/
MIT License
299 stars 29 forks source link

Snapshooter is broken for .NET 4.6.2 projects #194

Closed fgreinacher closed 8 months ago

fgreinacher commented 8 months ago

Describe the bug

The changes from https://github.com/SwissLife-OSS/snapshooter/pull/188 (specifically the discussion https://github.com/SwissLife-OSS/snapshooter/pull/188#discussion_r1416946886) broke scenarios where a NET Framework 4.6.2 test project references both Snapshooter as well NUnit 4. This happens because the Snapshooter build for .NET Standard 2.0 is compiled against NUnit 3.

To Reproduce

I made a minimal reproduction at https://github.com/fgreinacher/snapshooter-net462.

The failure can be seen at https://github.com/fgreinacher/snapshooter-net462/actions/runs/7449195601/job/20265287704:

  Error Message:
   System.MissingMethodException : Method not found: 'Void NUnit.Framework.Assert.That(!!0, NUnit.Framework.Constraints.IResolveConstraint)'.
  Stack Trace:
     at Snapshooter.NUnit.NUnitAssert.Assert(String expectedSnapshot, String actualSnapshot)
   at Snapshooter.SnapshotAssert.ExecuteSnapshotComparison(Boolean originalSnapshotExists, String actualSnapshotSerialized, String originalSnapshotSerialized, SnapshotFullName snapshotFullName, MatchOptions matchOptions)
   at Snapshooter.SnapshotAssert.AssertSnapshot(Object currentResult, SnapshotFullName snapshotFullName, MatchOptions matchOptions)
   at Snapshooter.NUnit.Snapshot.Match(Object currentResult, SnapshotFullName snapshotFullName, Func`2 matchOptions)
   at Snapshooter.NUnit.Snapshot.Match[T](T currentResult, Func`2 matchOptions)
   at snapshooter_net462.Tests.Test1() in D:\a\snapshooter-net462\snapshooter-net462\UnitTest1.cs:line 12

Expected behavior

This should work as both NUnit 4 and Snapshooter support .NET Framework 4.6.2

Desktop (please complete the following information):

fgreinacher commented 8 months ago

Microsoft suggests this:

✔️ CONSIDER multi-targeting even if your source code is the same for all targets, when your project has any library or package dependencies.

✔️ CONSIDER adding a target for net462 when you're offering a netstandard2.0 target.

Therefore I'd recommend to add a net462 target (which is still supported by NUnit 4).

WDYT @RohrerF @PascalSenn @daghsentinel?

RohrerF commented 8 months ago

Should be fixed in v14.0.1