diff --git a/src/ApprovalTests/Reporters/TestFrameworks/FrameworkAssertReporter.cs b/src/ApprovalTests/Reporters/TestFrameworks/FrameworkAssertReporter.cs index 5e2c94dd..c821a6d6 100644 --- a/src/ApprovalTests/Reporters/TestFrameworks/FrameworkAssertReporter.cs +++ b/src/ApprovalTests/Reporters/TestFrameworks/FrameworkAssertReporter.cs @@ -7,8 +7,8 @@ public class FrameworkAssertReporter : FirstWorkingReporter public FrameworkAssertReporter() : base( MsTestReporter.INSTANCE, - NUnit3Reporter.INSTANCE, NUnit4Reporter.INSTANCE, + NUnit3Reporter.INSTANCE, XUnit2Reporter.INSTANCE) { } diff --git a/src/ApprovalTests/Reporters/TestFrameworks/NUnit4Reporter.cs b/src/ApprovalTests/Reporters/TestFrameworks/NUnit4Reporter.cs index f65e07e1..f4d8cf48 100644 --- a/src/ApprovalTests/Reporters/TestFrameworks/NUnit4Reporter.cs +++ b/src/ApprovalTests/Reporters/TestFrameworks/NUnit4Reporter.cs @@ -3,6 +3,22 @@ namespace ApprovalTests.Reporters.TestFrameworks; public class NUnit4Reporter : AssertReporter { public readonly static NUnit4Reporter INSTANCE = new(); + static readonly Lazy isNUnit4 = new(IsisNUnit4); + + static bool IsisNUnit4() + { + return AppDomain + .CurrentDomain + .GetAssemblies() + .Any(_ => + { + var name = _.FullName; + return name.Contains("nunit.framework.legacy"); + }); + } + + public override bool IsWorkingInThisEnvironment(string forFile) => + base.IsWorkingInThisEnvironment(forFile) && isNUnit4.Value; public NUnit4Reporter() : base("NUnit.Framework.Legacy.ClassicAssert, nunit.framework.legacy", "AreEqual", NUnitStackTraceParser.Attribute)