Improve test failure msg (dotnet/corefx#42247)
authorDan Moseley <danmose@microsoft.com>
Thu, 31 Oct 2019 01:54:28 +0000 (18:54 -0700)
committermsftbot[bot] <48340428+msftbot[bot]@users.noreply.github.com>
Thu, 31 Oct 2019 01:54:28 +0000 (01:54 +0000)
Commit migrated from https://github.com/dotnet/corefx/commit/253f0d565c132bc98d9cf52c04c662a3373b49c4

src/libraries/System.ComponentModel.Composition/tests/System/ComponentModel/Composition/CompositionExceptionTests.cs

index 50aafac27f7eea403a715fe93ce0baf952990770..032baa1b24c5e9d7419b3bd2b7e5a1e4f4006415 100644 (file)
@@ -14,6 +14,7 @@ using System.Text;
 using System.UnitTesting;
 using Microsoft.DotNet.RemoteExecutor;
 using Xunit;
+using Xunit.Sdk;
 
 namespace System.ComponentModel.Composition
 {
@@ -416,10 +417,12 @@ namespace System.ComponentModel.Composition
                 }
                 else
                 {
-                    Assert.True(
-                        line.Contains(string.Format(CultureInfo.CurrentCulture, SR.CompositionException_SingleErrorWithMultiplePaths, rootCauseCount)) ||
-                        line.Contains(string.Format(CultureInfo.CurrentCulture, SR.CompositionException_MultipleErrorsWithMultiplePaths, rootCauseCount))
-                        );
+                    string option1 = string.Format(CultureInfo.CurrentCulture, SR.CompositionException_SingleErrorWithMultiplePaths, rootCauseCount);
+                    string option2 = string.Format(CultureInfo.CurrentCulture, SR.CompositionException_MultipleErrorsWithMultiplePaths, rootCauseCount);
+                    if (!line.Contains(option1) && !line.Contains(option2))
+                    {
+                        throw new XunitException($"`{line}` contains neither `{option1}` nor `{option2}`");
+                    }
                 }
             }
         }