From d9d1e85d54827d4171e6555ba8a2302e58dfba8d Mon Sep 17 00:00:00 2001 From: Marc Paine Date: Thu, 14 Dec 2023 16:55:39 -0800 Subject: [PATCH 1/8] Update the fluent assertions version to improve test failure output. Include a failing tests to verify. --- test/EndToEnd/ProjectBuildTests.cs | 2 +- .../Assertions/CommandResultAssertions.cs | 6 +++--- test/core-sdk-tasks.Tests/core-sdk-tasks.Tests.csproj | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/EndToEnd/ProjectBuildTests.cs b/test/EndToEnd/ProjectBuildTests.cs index 01925eb5f..0e5b8bb4b 100644 --- a/test/EndToEnd/ProjectBuildTests.cs +++ b/test/EndToEnd/ProjectBuildTests.cs @@ -82,7 +82,7 @@ namespace EndToEnd.Tests var runCommand = new RunCommand() .WithWorkingDirectory(projectDirectory) .ExecuteWithCapturedOutput() - .Should().Pass().And.HaveStdOutContaining("Hello, World!"); + .Should().Pass().And.HaveStdOutContaining("Hello, World!ds"); } [WindowsOnlyTheory] diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs index 7301d9a81..c140ec1cd 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs @@ -42,7 +42,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint HaveStdOut() { Execute.Assertion.ForCondition(!string.IsNullOrEmpty(_commandResult.StdOut)) - .FailWith(AppendDiagnosticsTo("Command did not output anything to stdout")); + .FailWith(AppendDiagnosticsTo($"Command did not output anything to stdout")); return new AndConstraint(this); } @@ -97,7 +97,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint HaveStdErr() { Execute.Assertion.ForCondition(!string.IsNullOrEmpty(_commandResult.StdErr)) - .FailWith(AppendDiagnosticsTo("Command did not output anything to stderr.")); + .FailWith(AppendDiagnosticsTo($"Command did not output anything to stderr.")); return new AndConstraint(this); } @@ -132,7 +132,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint NotHaveStdErr() { Execute.Assertion.ForCondition(string.IsNullOrEmpty(_commandResult.StdErr)) - .FailWith(AppendDiagnosticsTo("Expected command to not output to stderr but it was not:")); + .FailWith(AppendDiagnosticsTo($"Expected command to not output to stderr but it was not:")); return new AndConstraint(this); } diff --git a/test/core-sdk-tasks.Tests/core-sdk-tasks.Tests.csproj b/test/core-sdk-tasks.Tests/core-sdk-tasks.Tests.csproj index 47b6ce517..0e751c8ab 100644 --- a/test/core-sdk-tasks.Tests/core-sdk-tasks.Tests.csproj +++ b/test/core-sdk-tasks.Tests/core-sdk-tasks.Tests.csproj @@ -5,7 +5,7 @@ - + From f4311e2723cafabaa3678fa510e51ffe9ad203fd Mon Sep 17 00:00:00 2001 From: Marc Paine Date: Fri, 15 Dec 2023 09:43:15 -0800 Subject: [PATCH 2/8] Add FailWithPreformatted which saves the failure message before it gets reformated by fluent --- .../Assertions/AssertionScopeExtensions.cs | 20 ++++++++++++ .../Assertions/CommandResultAssertions.cs | 32 +++++++++---------- 2 files changed, 36 insertions(+), 16 deletions(-) create mode 100644 test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/AssertionScopeExtensions.cs diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/AssertionScopeExtensions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/AssertionScopeExtensions.cs new file mode 100644 index 000000000..4256b1ef7 --- /dev/null +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/AssertionScopeExtensions.cs @@ -0,0 +1,20 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using FluentAssertions.Execution; + +namespace Microsoft.DotNet.Tools.Test.Utilities +{ + public static class AssertionScopeExtensions + { + public static Continuation FailWithPreformatted(this AssertionScope assertionScope, string message) + { + if (!assertionScope.Succeeded) + { + assertionScope.AddFailure(message); + } + + return new Continuation(assertionScope, assertionScope.Succeeded); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs index c140ec1cd..e6bf83b15 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs @@ -21,35 +21,35 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint ExitWith(int expectedExitCode) { Execute.Assertion.ForCondition(_commandResult.ExitCode == expectedExitCode) - .FailWith(AppendDiagnosticsTo($"Expected command to exit with {expectedExitCode} but it did not.")); + .FailWithPreformatted(AppendDiagnosticsTo($"Expected command to exit with {expectedExitCode} but it did not.")); return new AndConstraint(this); } public AndConstraint Pass() { Execute.Assertion.ForCondition(_commandResult.ExitCode == 0) - .FailWith(AppendDiagnosticsTo($"Expected command to pass but it did not.")); + .FailWithPreformatted(AppendDiagnosticsTo($"Expected command to pass but it did not.")); return new AndConstraint(this); } public AndConstraint Fail() { Execute.Assertion.ForCondition(_commandResult.ExitCode != 0) - .FailWith(AppendDiagnosticsTo($"Expected command to fail but it did not.")); + .FailWithPreformatted(AppendDiagnosticsTo($"Expected command to fail but it did not.")); return new AndConstraint(this); } public AndConstraint HaveStdOut() { Execute.Assertion.ForCondition(!string.IsNullOrEmpty(_commandResult.StdOut)) - .FailWith(AppendDiagnosticsTo($"Command did not output anything to stdout")); + .FailWithPreformatted(AppendDiagnosticsTo($"Command did not output anything to stdout")); return new AndConstraint(this); } public AndConstraint HaveStdOut(string expectedOutput) { Execute.Assertion.ForCondition(_commandResult.StdOut.Equals(expectedOutput, StringComparison.Ordinal)) - .FailWith(AppendDiagnosticsTo($"Command did not output with Expected Output. Expected: {expectedOutput}")); + .FailWithPreformatted(AppendDiagnosticsTo($"Command did not output with Expected Output. Expected: {expectedOutput}")); return new AndConstraint(this); } @@ -57,7 +57,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { Execute.Assertion .ForCondition(_commandResult.StdOut.Contains(pattern)) - .FailWith(AppendDiagnosticsTo($"The command output did not contain expected result: {pattern}{Environment.NewLine}")); + .FailWithPreformatted(AppendDiagnosticsTo($"The command output did not contain expected result: {pattern}{Environment.NewLine}")); return new AndConstraint(this); } @@ -68,7 +68,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(commandResultNoSpaces.Contains(pattern)) - .FailWith(AppendDiagnosticsTo($"The command output did not contain expected result: {pattern}{Environment.NewLine}")); + .FailWithPreformatted(AppendDiagnosticsTo($"The command output did not contain expected result: {pattern}{Environment.NewLine}")); return new AndConstraint(this); } @@ -76,63 +76,63 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint HaveStdOutContainingIgnoreCase(string pattern) { Execute.Assertion.ForCondition(_commandResult.StdOut.IndexOf(pattern, StringComparison.OrdinalIgnoreCase) >= 0) - .FailWith(AppendDiagnosticsTo($"The command output did not contain expected result (ignoring case): {pattern}{Environment.NewLine}")); + .FailWithPreformatted(AppendDiagnosticsTo($"The command output did not contain expected result (ignoring case): {pattern}{Environment.NewLine}")); return new AndConstraint(this); } public AndConstraint NotHaveStdOutContaining(string pattern) { Execute.Assertion.ForCondition(!_commandResult.StdOut.Contains(pattern)) - .FailWith(AppendDiagnosticsTo($"The command output contained a result it should not have contained: {pattern}{Environment.NewLine}")); + .FailWithPreformatted(AppendDiagnosticsTo($"The command output contained a result it should not have contained: {pattern}{Environment.NewLine}")); return new AndConstraint(this); } public AndConstraint HaveStdOutMatching(string pattern, RegexOptions options = RegexOptions.None) { Execute.Assertion.ForCondition(Regex.Match(_commandResult.StdOut, pattern, options).Success) - .FailWith(AppendDiagnosticsTo($"Matching the command output failed. Pattern: {pattern}{Environment.NewLine}")); + .FailWithPreformatted(AppendDiagnosticsTo($"Matching the command output failed. Pattern: {pattern}{Environment.NewLine}")); return new AndConstraint(this); } public AndConstraint HaveStdErr() { Execute.Assertion.ForCondition(!string.IsNullOrEmpty(_commandResult.StdErr)) - .FailWith(AppendDiagnosticsTo($"Command did not output anything to stderr.")); + .FailWithPreformatted(AppendDiagnosticsTo($"Command did not output anything to stderr.")); return new AndConstraint(this); } public AndConstraint HaveStdErrContaining(string pattern) { Execute.Assertion.ForCondition(_commandResult.StdErr.Contains(pattern)) - .FailWith(AppendDiagnosticsTo($"The command error output did not contain expected result: {pattern}{Environment.NewLine}")); + .FailWithPreformatted(AppendDiagnosticsTo($"The command error output did not contain expected result: {pattern}{Environment.NewLine}")); return new AndConstraint(this); } public AndConstraint NotHaveStdErrContaining(string pattern) { Execute.Assertion.ForCondition(!_commandResult.StdErr.Contains(pattern)) - .FailWith(AppendDiagnosticsTo($"The command error output contained a result it should not have contained: {pattern}{Environment.NewLine}")); + .FailWithPreformatted(AppendDiagnosticsTo($"The command error output contained a result it should not have contained: {pattern}{Environment.NewLine}")); return new AndConstraint(this); } public AndConstraint HaveStdErrMatching(string pattern, RegexOptions options = RegexOptions.None) { Execute.Assertion.ForCondition(Regex.Match(_commandResult.StdErr, pattern, options).Success) - .FailWith(AppendDiagnosticsTo($"Matching the command error output failed. Pattern: {pattern}{Environment.NewLine}")); + .FailWithPreformatted(AppendDiagnosticsTo($"Matching the command error output failed. Pattern: {pattern}{Environment.NewLine}")); return new AndConstraint(this); } public AndConstraint NotHaveStdOut() { Execute.Assertion.ForCondition(string.IsNullOrEmpty(_commandResult.StdOut)) - .FailWith(AppendDiagnosticsTo($"Expected command to not output to stdout but it was not:")); + .FailWithPreformatted(AppendDiagnosticsTo($"Expected command to not output to stdout but it was not:")); return new AndConstraint(this); } public AndConstraint NotHaveStdErr() { Execute.Assertion.ForCondition(string.IsNullOrEmpty(_commandResult.StdErr)) - .FailWith(AppendDiagnosticsTo($"Expected command to not output to stderr but it was not:")); + .FailWithPreformatted(AppendDiagnosticsTo($"Expected command to not output to stderr but it was not:")); return new AndConstraint(this); } From 636f714882fe44351e43d32d0b6326c0eaf32b64 Mon Sep 17 00:00:00 2001 From: Marc Paine Date: Tue, 2 Jan 2024 15:31:52 -0800 Subject: [PATCH 3/8] Update to call FailWithPreformatted --- .../Assertions/DirectoryInfoAssertions.cs | 26 +++++++++---------- .../Assertions/FileInfoAssertions.cs | 4 +-- .../Assertions/StringAssertionsExtensions.cs | 4 +-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoAssertions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoAssertions.cs index adb83caf2..6e658d848 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoAssertions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoAssertions.cs @@ -26,7 +26,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint Exist() { Execute.Assertion.ForCondition(_dirInfo.Exists) - .FailWith("Expected directory {0} does not exist.", _dirInfo.FullName); + .FailWithPreformatted("Expected directory {0} does not exist.", _dirInfo.FullName); return new AndConstraint(this); } @@ -37,7 +37,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(file != null) .BecauseOf(because, reasonArgs) - .FailWith($"Expected File {expectedFile} cannot be found in directory {_dirInfo.FullName}."); + .FailWithPreformatted($"Expected File {expectedFile} cannot be found in directory {_dirInfo.FullName}."); return new AndConstraint(this); } @@ -57,7 +57,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(contents.Equals(expectedContents)) .BecauseOf(because, reasonArgs) - .FailWith($"Expected file {expectedFile} to contain \n\n{expectedContents}\n\nbut it contains\n\n{contents}\n"); + .FailWithPreformatted($"Expected file {expectedFile} to contain \n\n{expectedContents}\n\nbut it contains\n\n{contents}\n"); return new AndConstraint(this); } @@ -71,7 +71,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(file == null) .BecauseOf(because, reasonArgs) - .FailWith("File {0} should not be found in directory {1}.", expectedFile, _dirInfo.FullName); + .FailWithPreformatted("File {0} should not be found in directory {1}.", expectedFile, _dirInfo.FullName); return new AndConstraint(this); } @@ -109,7 +109,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(matchingFileExists == true) .BecauseOf(because, reasonArgs) - .FailWith("Expected directory {0} to contain files matching {1}, but no matching file exists.", + .FailWithPreformatted("Expected directory {0} to contain files matching {1}, but no matching file exists.", _dirInfo.FullName, expectedFilesSearchPattern); return new AndConstraint(this); @@ -132,7 +132,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { var matchingFileCount = _dirInfo.EnumerateFiles(expectedFilesSearchPattern, searchOption).Count(); Execute.Assertion.ForCondition(matchingFileCount == 0) - .FailWith("Found {0} files that should not exist in directory {1}. No file matching {2} should exist.", + .FailWithPreformatted("Found {0} files that should not exist in directory {1}. No file matching {2} should exist.", matchingFileCount, _dirInfo.FullName, expectedFilesSearchPattern); return new AndConstraint(this); } @@ -141,7 +141,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { var dir = _dirInfo.EnumerateDirectories(expectedDir, SearchOption.TopDirectoryOnly).SingleOrDefault(); Execute.Assertion.ForCondition(dir != null) - .FailWith("Expected directory {0} cannot be found inside directory {1}.", expectedDir, _dirInfo.FullName); + .FailWithPreformatted("Expected directory {0} cannot be found inside directory {1}.", expectedDir, _dirInfo.FullName); return new AndConstraint(new DirectoryInfoAssertions(dir)); } @@ -160,7 +160,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { var dir = _dirInfo.EnumerateDirectories(unexpectedDir, SearchOption.TopDirectoryOnly).SingleOrDefault(); Execute.Assertion.ForCondition(dir == null) - .FailWith("Directory {0} should not be found in directory {1}.", unexpectedDir, _dirInfo.FullName); + .FailWithPreformatted("Directory {0} should not be found in directory {1}.", unexpectedDir, _dirInfo.FullName); return new AndConstraint(new DirectoryInfoAssertions(dir)); } @@ -183,10 +183,10 @@ namespace Microsoft.DotNet.Tools.Test.Utilities var nl = Environment.NewLine; Execute.Assertion.ForCondition(!missingFiles.Any()) - .FailWith($"Following files cannot be found inside directory {_dirInfo.FullName} {nl} {string.Join(nl, missingFiles)}"); + .FailWithPreformatted($"Following files cannot be found inside directory {_dirInfo.FullName} {nl} {string.Join(nl, missingFiles)}"); Execute.Assertion.ForCondition(!extraFiles.Any()) - .FailWith($"Following extra files are found inside directory {_dirInfo.FullName} {nl} {string.Join(nl, extraFiles)}"); + .FailWithPreformatted($"Following extra files are found inside directory {_dirInfo.FullName} {nl} {string.Join(nl, extraFiles)}"); return new AndConstraint(this); } @@ -194,7 +194,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint BeEmpty() { Execute.Assertion.ForCondition(!_dirInfo.EnumerateFileSystemInfos().Any()) - .FailWith($"The directory {_dirInfo.FullName} is not empty."); + .FailWithPreformatted($"The directory {_dirInfo.FullName} is not empty."); return new AndConstraint(this); } @@ -202,7 +202,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint NotBeEmpty() { Execute.Assertion.ForCondition(_dirInfo.EnumerateFileSystemInfos().Any()) - .FailWith($"The directory {_dirInfo.FullName} is empty."); + .FailWithPreformatted($"The directory {_dirInfo.FullName} is empty."); return new AndConstraint(this); } @@ -212,7 +212,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(_dirInfo.Exists == false) .BecauseOf(because, reasonArgs) - .FailWith($"Expected directory {_dirInfo.FullName} to not exist, but it does."); + .FailWithPreformatted($"Expected directory {_dirInfo.FullName} to not exist, but it does."); return new AndConstraint(this); } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoAssertions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoAssertions.cs index dca27f0c5..f5d1d84a2 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoAssertions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoAssertions.cs @@ -28,7 +28,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(_fileInfo.Exists) .BecauseOf(because, reasonArgs) - .FailWith($"Expected File {_fileInfo.FullName} to exist, but it does not."); + .FailWithPreformatted($"Expected File {_fileInfo.FullName} to exist, but it does not."); return new AndConstraint(this); } @@ -37,7 +37,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(!_fileInfo.Exists) .BecauseOf(because, reasonArgs) - .FailWith($"Expected File {_fileInfo.FullName} to not exist, but it does."); + .FailWithPreformatted($"Expected File {_fileInfo.FullName} to not exist, but it does."); return new AndConstraint(this); } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/StringAssertionsExtensions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/StringAssertionsExtensions.cs index e0483c39a..799809879 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/StringAssertionsExtensions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/StringAssertionsExtensions.cs @@ -20,7 +20,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(NormalizeLineEndings(assertions.Subject) == NormalizeLineEndings(expected)) .BecauseOf(because, becauseArgs) - .FailWith($"String \"{assertions.Subject}\" is not visually equivalent to expected string \"{expected}\"."); + .FailWithPreformatted($"String \"{assertions.Subject}\" is not visually equivalent to expected string \"{expected}\"."); return new AndConstraint(assertions); } @@ -30,7 +30,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(NormalizeLineEndings(assertions.Subject).Contains(NormalizeLineEndings(expected))) .BecauseOf(because, becauseArgs) - .FailWith($"String \"{assertions.Subject}\" does not contain visually same fragment string \"{expected}\"."); + .FailWithPreformatted($"String \"{assertions.Subject}\" does not contain visually same fragment string \"{expected}\"."); return new AndConstraint(assertions); } From 7ad11327958c321d112bf521780e4a5fa76c3320 Mon Sep 17 00:00:00 2001 From: Marc Paine Date: Tue, 9 Jan 2024 16:12:12 -0800 Subject: [PATCH 4/8] Switch to addpreformattedfailure --- .../Assertions/AssertionScopeExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/AssertionScopeExtensions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/AssertionScopeExtensions.cs index 4256b1ef7..54a567eb3 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/AssertionScopeExtensions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/AssertionScopeExtensions.cs @@ -11,10 +11,10 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { if (!assertionScope.Succeeded) { - assertionScope.AddFailure(message); + assertionScope.AddPreFormattedFailure(message); } return new Continuation(assertionScope, assertionScope.Succeeded); } } -} \ No newline at end of file +} From c9b14717bcd029fad2dfbfbc4b40eeb887ffa8ca Mon Sep 17 00:00:00 2001 From: Marc Paine Date: Thu, 11 Jan 2024 15:42:20 -0800 Subject: [PATCH 5/8] Looks like i missed a fluent assertions update in the test utilities csproj so trying that to see if it is enough to solve the output issue. --- test/EndToEnd/ValidateInsertedManifests.cs | 2 +- .../Assertions/AssertionScopeExtensions.cs | 20 ------------ .../Assertions/CommandResultAssertions.cs | 32 +++++++++---------- .../Assertions/DirectoryInfoAssertions.cs | 30 ++++++++--------- .../Assertions/FileInfoAssertions.cs | 4 +-- .../Assertions/StringAssertionsExtensions.cs | 4 +-- ...rosoft.DotNet.Tools.Tests.Utilities.csproj | 2 +- 7 files changed, 37 insertions(+), 57 deletions(-) delete mode 100644 test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/AssertionScopeExtensions.cs diff --git a/test/EndToEnd/ValidateInsertedManifests.cs b/test/EndToEnd/ValidateInsertedManifests.cs index cdede126c..0b2668afc 100644 --- a/test/EndToEnd/ValidateInsertedManifests.cs +++ b/test/EndToEnd/ValidateInsertedManifests.cs @@ -34,7 +34,7 @@ namespace EndToEnd.Tests File.Exists(manifestFile).Should().BeTrue(); using var fileStream = new FileStream(manifestFile, FileMode.Open, FileAccess.Read); Action readManifest = () => WorkloadManifestReader.ReadWorkloadManifest(manifestId, fileStream, manifestFile); - readManifest.ShouldNotThrow("manifestId:" + manifestId + " manifestFile:" + manifestFile + "is invalid"); + readManifest.Should().NotThrow("manifestId:" + manifestId + " manifestFile:" + manifestFile + "is invalid"); } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/AssertionScopeExtensions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/AssertionScopeExtensions.cs deleted file mode 100644 index 54a567eb3..000000000 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/AssertionScopeExtensions.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using FluentAssertions.Execution; - -namespace Microsoft.DotNet.Tools.Test.Utilities -{ - public static class AssertionScopeExtensions - { - public static Continuation FailWithPreformatted(this AssertionScope assertionScope, string message) - { - if (!assertionScope.Succeeded) - { - assertionScope.AddPreFormattedFailure(message); - } - - return new Continuation(assertionScope, assertionScope.Succeeded); - } - } -} diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs index e6bf83b15..c140ec1cd 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs @@ -21,35 +21,35 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint ExitWith(int expectedExitCode) { Execute.Assertion.ForCondition(_commandResult.ExitCode == expectedExitCode) - .FailWithPreformatted(AppendDiagnosticsTo($"Expected command to exit with {expectedExitCode} but it did not.")); + .FailWith(AppendDiagnosticsTo($"Expected command to exit with {expectedExitCode} but it did not.")); return new AndConstraint(this); } public AndConstraint Pass() { Execute.Assertion.ForCondition(_commandResult.ExitCode == 0) - .FailWithPreformatted(AppendDiagnosticsTo($"Expected command to pass but it did not.")); + .FailWith(AppendDiagnosticsTo($"Expected command to pass but it did not.")); return new AndConstraint(this); } public AndConstraint Fail() { Execute.Assertion.ForCondition(_commandResult.ExitCode != 0) - .FailWithPreformatted(AppendDiagnosticsTo($"Expected command to fail but it did not.")); + .FailWith(AppendDiagnosticsTo($"Expected command to fail but it did not.")); return new AndConstraint(this); } public AndConstraint HaveStdOut() { Execute.Assertion.ForCondition(!string.IsNullOrEmpty(_commandResult.StdOut)) - .FailWithPreformatted(AppendDiagnosticsTo($"Command did not output anything to stdout")); + .FailWith(AppendDiagnosticsTo($"Command did not output anything to stdout")); return new AndConstraint(this); } public AndConstraint HaveStdOut(string expectedOutput) { Execute.Assertion.ForCondition(_commandResult.StdOut.Equals(expectedOutput, StringComparison.Ordinal)) - .FailWithPreformatted(AppendDiagnosticsTo($"Command did not output with Expected Output. Expected: {expectedOutput}")); + .FailWith(AppendDiagnosticsTo($"Command did not output with Expected Output. Expected: {expectedOutput}")); return new AndConstraint(this); } @@ -57,7 +57,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { Execute.Assertion .ForCondition(_commandResult.StdOut.Contains(pattern)) - .FailWithPreformatted(AppendDiagnosticsTo($"The command output did not contain expected result: {pattern}{Environment.NewLine}")); + .FailWith(AppendDiagnosticsTo($"The command output did not contain expected result: {pattern}{Environment.NewLine}")); return new AndConstraint(this); } @@ -68,7 +68,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(commandResultNoSpaces.Contains(pattern)) - .FailWithPreformatted(AppendDiagnosticsTo($"The command output did not contain expected result: {pattern}{Environment.NewLine}")); + .FailWith(AppendDiagnosticsTo($"The command output did not contain expected result: {pattern}{Environment.NewLine}")); return new AndConstraint(this); } @@ -76,63 +76,63 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint HaveStdOutContainingIgnoreCase(string pattern) { Execute.Assertion.ForCondition(_commandResult.StdOut.IndexOf(pattern, StringComparison.OrdinalIgnoreCase) >= 0) - .FailWithPreformatted(AppendDiagnosticsTo($"The command output did not contain expected result (ignoring case): {pattern}{Environment.NewLine}")); + .FailWith(AppendDiagnosticsTo($"The command output did not contain expected result (ignoring case): {pattern}{Environment.NewLine}")); return new AndConstraint(this); } public AndConstraint NotHaveStdOutContaining(string pattern) { Execute.Assertion.ForCondition(!_commandResult.StdOut.Contains(pattern)) - .FailWithPreformatted(AppendDiagnosticsTo($"The command output contained a result it should not have contained: {pattern}{Environment.NewLine}")); + .FailWith(AppendDiagnosticsTo($"The command output contained a result it should not have contained: {pattern}{Environment.NewLine}")); return new AndConstraint(this); } public AndConstraint HaveStdOutMatching(string pattern, RegexOptions options = RegexOptions.None) { Execute.Assertion.ForCondition(Regex.Match(_commandResult.StdOut, pattern, options).Success) - .FailWithPreformatted(AppendDiagnosticsTo($"Matching the command output failed. Pattern: {pattern}{Environment.NewLine}")); + .FailWith(AppendDiagnosticsTo($"Matching the command output failed. Pattern: {pattern}{Environment.NewLine}")); return new AndConstraint(this); } public AndConstraint HaveStdErr() { Execute.Assertion.ForCondition(!string.IsNullOrEmpty(_commandResult.StdErr)) - .FailWithPreformatted(AppendDiagnosticsTo($"Command did not output anything to stderr.")); + .FailWith(AppendDiagnosticsTo($"Command did not output anything to stderr.")); return new AndConstraint(this); } public AndConstraint HaveStdErrContaining(string pattern) { Execute.Assertion.ForCondition(_commandResult.StdErr.Contains(pattern)) - .FailWithPreformatted(AppendDiagnosticsTo($"The command error output did not contain expected result: {pattern}{Environment.NewLine}")); + .FailWith(AppendDiagnosticsTo($"The command error output did not contain expected result: {pattern}{Environment.NewLine}")); return new AndConstraint(this); } public AndConstraint NotHaveStdErrContaining(string pattern) { Execute.Assertion.ForCondition(!_commandResult.StdErr.Contains(pattern)) - .FailWithPreformatted(AppendDiagnosticsTo($"The command error output contained a result it should not have contained: {pattern}{Environment.NewLine}")); + .FailWith(AppendDiagnosticsTo($"The command error output contained a result it should not have contained: {pattern}{Environment.NewLine}")); return new AndConstraint(this); } public AndConstraint HaveStdErrMatching(string pattern, RegexOptions options = RegexOptions.None) { Execute.Assertion.ForCondition(Regex.Match(_commandResult.StdErr, pattern, options).Success) - .FailWithPreformatted(AppendDiagnosticsTo($"Matching the command error output failed. Pattern: {pattern}{Environment.NewLine}")); + .FailWith(AppendDiagnosticsTo($"Matching the command error output failed. Pattern: {pattern}{Environment.NewLine}")); return new AndConstraint(this); } public AndConstraint NotHaveStdOut() { Execute.Assertion.ForCondition(string.IsNullOrEmpty(_commandResult.StdOut)) - .FailWithPreformatted(AppendDiagnosticsTo($"Expected command to not output to stdout but it was not:")); + .FailWith(AppendDiagnosticsTo($"Expected command to not output to stdout but it was not:")); return new AndConstraint(this); } public AndConstraint NotHaveStdErr() { Execute.Assertion.ForCondition(string.IsNullOrEmpty(_commandResult.StdErr)) - .FailWithPreformatted(AppendDiagnosticsTo($"Expected command to not output to stderr but it was not:")); + .FailWith(AppendDiagnosticsTo($"Expected command to not output to stderr but it was not:")); return new AndConstraint(this); } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoAssertions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoAssertions.cs index 6e658d848..74b45b8db 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoAssertions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/DirectoryInfoAssertions.cs @@ -26,7 +26,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint Exist() { Execute.Assertion.ForCondition(_dirInfo.Exists) - .FailWithPreformatted("Expected directory {0} does not exist.", _dirInfo.FullName); + .FailWith(String.Format("Expected directory {0} does not exist.", _dirInfo.FullName)); return new AndConstraint(this); } @@ -37,7 +37,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(file != null) .BecauseOf(because, reasonArgs) - .FailWithPreformatted($"Expected File {expectedFile} cannot be found in directory {_dirInfo.FullName}."); + .FailWith($"Expected File {expectedFile} cannot be found in directory {_dirInfo.FullName}."); return new AndConstraint(this); } @@ -57,7 +57,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(contents.Equals(expectedContents)) .BecauseOf(because, reasonArgs) - .FailWithPreformatted($"Expected file {expectedFile} to contain \n\n{expectedContents}\n\nbut it contains\n\n{contents}\n"); + .FailWith($"Expected file {expectedFile} to contain \n\n{expectedContents}\n\nbut it contains\n\n{contents}\n"); return new AndConstraint(this); } @@ -71,7 +71,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(file == null) .BecauseOf(because, reasonArgs) - .FailWithPreformatted("File {0} should not be found in directory {1}.", expectedFile, _dirInfo.FullName); + .FailWith(String.Format("File {0} should not be found in directory {1}.", expectedFile, _dirInfo.FullName)); return new AndConstraint(this); } @@ -109,8 +109,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(matchingFileExists == true) .BecauseOf(because, reasonArgs) - .FailWithPreformatted("Expected directory {0} to contain files matching {1}, but no matching file exists.", - _dirInfo.FullName, expectedFilesSearchPattern); + .FailWith(String.Format("Expected directory {0} to contain files matching {1}, but no matching file exists.", + _dirInfo.FullName, expectedFilesSearchPattern)); return new AndConstraint(this); } @@ -132,8 +132,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { var matchingFileCount = _dirInfo.EnumerateFiles(expectedFilesSearchPattern, searchOption).Count(); Execute.Assertion.ForCondition(matchingFileCount == 0) - .FailWithPreformatted("Found {0} files that should not exist in directory {1}. No file matching {2} should exist.", - matchingFileCount, _dirInfo.FullName, expectedFilesSearchPattern); + .FailWith(String.Format("Found {0} files that should not exist in directory {1}. No file matching {2} should exist.", + matchingFileCount, _dirInfo.FullName, expectedFilesSearchPattern)); return new AndConstraint(this); } @@ -141,7 +141,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { var dir = _dirInfo.EnumerateDirectories(expectedDir, SearchOption.TopDirectoryOnly).SingleOrDefault(); Execute.Assertion.ForCondition(dir != null) - .FailWithPreformatted("Expected directory {0} cannot be found inside directory {1}.", expectedDir, _dirInfo.FullName); + .FailWith(String.Format("Expected directory {0} cannot be found inside directory {1}.", expectedDir, _dirInfo.FullName)); return new AndConstraint(new DirectoryInfoAssertions(dir)); } @@ -160,7 +160,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { var dir = _dirInfo.EnumerateDirectories(unexpectedDir, SearchOption.TopDirectoryOnly).SingleOrDefault(); Execute.Assertion.ForCondition(dir == null) - .FailWithPreformatted("Directory {0} should not be found in directory {1}.", unexpectedDir, _dirInfo.FullName); + .FailWith(String.Format("Directory {0} should not be found in directory {1}.", unexpectedDir, _dirInfo.FullName)); return new AndConstraint(new DirectoryInfoAssertions(dir)); } @@ -183,10 +183,10 @@ namespace Microsoft.DotNet.Tools.Test.Utilities var nl = Environment.NewLine; Execute.Assertion.ForCondition(!missingFiles.Any()) - .FailWithPreformatted($"Following files cannot be found inside directory {_dirInfo.FullName} {nl} {string.Join(nl, missingFiles)}"); + .FailWith($"Following files cannot be found inside directory {_dirInfo.FullName} {nl} {string.Join(nl, missingFiles)}"); Execute.Assertion.ForCondition(!extraFiles.Any()) - .FailWithPreformatted($"Following extra files are found inside directory {_dirInfo.FullName} {nl} {string.Join(nl, extraFiles)}"); + .FailWith($"Following extra files are found inside directory {_dirInfo.FullName} {nl} {string.Join(nl, extraFiles)}"); return new AndConstraint(this); } @@ -194,7 +194,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint BeEmpty() { Execute.Assertion.ForCondition(!_dirInfo.EnumerateFileSystemInfos().Any()) - .FailWithPreformatted($"The directory {_dirInfo.FullName} is not empty."); + .FailWith($"The directory {_dirInfo.FullName} is not empty."); return new AndConstraint(this); } @@ -202,7 +202,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint NotBeEmpty() { Execute.Assertion.ForCondition(_dirInfo.EnumerateFileSystemInfos().Any()) - .FailWithPreformatted($"The directory {_dirInfo.FullName} is empty."); + .FailWith($"The directory {_dirInfo.FullName} is empty."); return new AndConstraint(this); } @@ -212,7 +212,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(_dirInfo.Exists == false) .BecauseOf(because, reasonArgs) - .FailWithPreformatted($"Expected directory {_dirInfo.FullName} to not exist, but it does."); + .FailWith($"Expected directory {_dirInfo.FullName} to not exist, but it does."); return new AndConstraint(this); } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoAssertions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoAssertions.cs index f5d1d84a2..dca27f0c5 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoAssertions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/FileInfoAssertions.cs @@ -28,7 +28,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(_fileInfo.Exists) .BecauseOf(because, reasonArgs) - .FailWithPreformatted($"Expected File {_fileInfo.FullName} to exist, but it does not."); + .FailWith($"Expected File {_fileInfo.FullName} to exist, but it does not."); return new AndConstraint(this); } @@ -37,7 +37,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(!_fileInfo.Exists) .BecauseOf(because, reasonArgs) - .FailWithPreformatted($"Expected File {_fileInfo.FullName} to not exist, but it does."); + .FailWith($"Expected File {_fileInfo.FullName} to not exist, but it does."); return new AndConstraint(this); } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/StringAssertionsExtensions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/StringAssertionsExtensions.cs index 799809879..e0483c39a 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/StringAssertionsExtensions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/StringAssertionsExtensions.cs @@ -20,7 +20,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(NormalizeLineEndings(assertions.Subject) == NormalizeLineEndings(expected)) .BecauseOf(because, becauseArgs) - .FailWithPreformatted($"String \"{assertions.Subject}\" is not visually equivalent to expected string \"{expected}\"."); + .FailWith($"String \"{assertions.Subject}\" is not visually equivalent to expected string \"{expected}\"."); return new AndConstraint(assertions); } @@ -30,7 +30,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities Execute.Assertion .ForCondition(NormalizeLineEndings(assertions.Subject).Contains(NormalizeLineEndings(expected))) .BecauseOf(because, becauseArgs) - .FailWithPreformatted($"String \"{assertions.Subject}\" does not contain visually same fragment string \"{expected}\"."); + .FailWith($"String \"{assertions.Subject}\" does not contain visually same fragment string \"{expected}\"."); return new AndConstraint(assertions); } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Microsoft.DotNet.Tools.Tests.Utilities.csproj b/test/Microsoft.DotNet.Tools.Tests.Utilities/Microsoft.DotNet.Tools.Tests.Utilities.csproj index 27da1cfb8..485ec5fad 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Microsoft.DotNet.Tools.Tests.Utilities.csproj +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Microsoft.DotNet.Tools.Tests.Utilities.csproj @@ -4,7 +4,7 @@ - + From ec45808e4418026611f41cd433856c072bacbc7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 22 Apr 2024 14:35:06 +0200 Subject: [PATCH 6/8] Use VSTest runner for tests --- Directory.Build.props | 2 ++ eng/build-pr.yml | 4 ++-- eng/build.yml | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 39b30a121..0d470e4a5 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -31,6 +31,8 @@ This is a prevalent problem in building the precomputed assembly reference cache. Limiting the assemblies resolved to those outside the culture folders would work, but that is a nontrivial problem. --> NU5125;NU5105;NU1701;MSB3243;MSB3247 + + true diff --git a/eng/build-pr.yml b/eng/build-pr.yml index 831d96781..e9a14cdf7 100644 --- a/eng/build-pr.yml +++ b/eng/build-pr.yml @@ -233,8 +233,8 @@ jobs: - task: PublishTestResults@2 displayName: Publish Test Results inputs: - testRunner: XUnit - testResultsFiles: 'artifacts/TestResults/${{ parameters.buildConfiguration }}/*.xml' + testRunner: VSTest + testResultsFiles: 'artifacts/TestResults/${{ parameters.buildConfiguration }}/*.trx' testRunTitle: '$(_AgentOSName)_$(Agent.JobName)' platform: '$(BuildPlatform)' configuration: '${{ parameters.buildConfiguration }}' diff --git a/eng/build.yml b/eng/build.yml index 4f947ea8f..d901233c4 100644 --- a/eng/build.yml +++ b/eng/build.yml @@ -239,8 +239,8 @@ jobs: - task: PublishTestResults@2 displayName: Publish Test Results inputs: - testRunner: XUnit - testResultsFiles: 'artifacts/TestResults/${{ parameters.buildConfiguration }}/*.xml' + testRunner: VSTest + testResultsFiles: 'artifacts/TestResults/${{ parameters.buildConfiguration }}/*.trx' testRunTitle: '$(_AgentOSName)_$(Agent.JobName)' platform: '$(BuildPlatform)' configuration: '${{ parameters.buildConfiguration }}' From 68acf81475b787e427697c1534ad8a21858fc560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Thu, 20 Jun 2024 14:31:27 +0200 Subject: [PATCH 7/8] Remove intentional error --- test/EndToEnd/ProjectBuildTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/EndToEnd/ProjectBuildTests.cs b/test/EndToEnd/ProjectBuildTests.cs index a3e4fa4e2..fa7350c16 100644 --- a/test/EndToEnd/ProjectBuildTests.cs +++ b/test/EndToEnd/ProjectBuildTests.cs @@ -82,7 +82,7 @@ namespace EndToEnd.Tests var runCommand = new RunCommand() .WithWorkingDirectory(projectDirectory) .ExecuteWithCapturedOutput() - .Should().Pass().And.HaveStdOutContaining("Hello, World!ds"); + .Should().Pass().And.HaveStdOutContaining("Hello, World!"); } [WindowsOnlyTheory] From cc62208676c7dd727e4b0fdbcd7aae58dbd575b9 Mon Sep 17 00:00:00 2001 From: Marc Paine Date: Wed, 3 Jul 2024 15:22:39 -0700 Subject: [PATCH 8/8] Respond to PR feedback in moving the UseVSTestRunner into the test DBPs file and removing the unnecessary $ in the command result assertion file --- Directory.Build.props | 2 -- test/Directory.Build.props | 1 + .../Assertions/CommandResultAssertions.cs | 12 ++++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 0d470e4a5..39b30a121 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -31,8 +31,6 @@ This is a prevalent problem in building the precomputed assembly reference cache. Limiting the assemblies resolved to those outside the culture folders would work, but that is a nontrivial problem. --> NU5125;NU5105;NU1701;MSB3243;MSB3247 - - true diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 26d486322..8369b6680 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -3,5 +3,6 @@ true + true diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs index c140ec1cd..2c883c418 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs @@ -28,21 +28,21 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint Pass() { Execute.Assertion.ForCondition(_commandResult.ExitCode == 0) - .FailWith(AppendDiagnosticsTo($"Expected command to pass but it did not.")); + .FailWith(AppendDiagnosticsTo("Expected command to pass but it did not.")); return new AndConstraint(this); } public AndConstraint Fail() { Execute.Assertion.ForCondition(_commandResult.ExitCode != 0) - .FailWith(AppendDiagnosticsTo($"Expected command to fail but it did not.")); + .FailWith(AppendDiagnosticsTo("Expected command to fail but it did not.")); return new AndConstraint(this); } public AndConstraint HaveStdOut() { Execute.Assertion.ForCondition(!string.IsNullOrEmpty(_commandResult.StdOut)) - .FailWith(AppendDiagnosticsTo($"Command did not output anything to stdout")); + .FailWith(AppendDiagnosticsTo("Command did not output anything to stdout")); return new AndConstraint(this); } @@ -97,7 +97,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint HaveStdErr() { Execute.Assertion.ForCondition(!string.IsNullOrEmpty(_commandResult.StdErr)) - .FailWith(AppendDiagnosticsTo($"Command did not output anything to stderr.")); + .FailWith(AppendDiagnosticsTo("Command did not output anything to stderr.")); return new AndConstraint(this); } @@ -125,14 +125,14 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint NotHaveStdOut() { Execute.Assertion.ForCondition(string.IsNullOrEmpty(_commandResult.StdOut)) - .FailWith(AppendDiagnosticsTo($"Expected command to not output to stdout but it was not:")); + .FailWith(AppendDiagnosticsTo("Expected command to not output to stdout but it was not:")); return new AndConstraint(this); } public AndConstraint NotHaveStdErr() { Execute.Assertion.ForCondition(string.IsNullOrEmpty(_commandResult.StdErr)) - .FailWith(AppendDiagnosticsTo($"Expected command to not output to stderr but it was not:")); + .FailWith(AppendDiagnosticsTo("Expected command to not output to stderr but it was not:")); return new AndConstraint(this); }