Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the fluent assertions version to improve test failure output. #17982

Merged
merged 10 commits into from
Jul 3, 2024
Merged
4 changes: 2 additions & 2 deletions eng/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}'
Expand Down
4 changes: 2 additions & 2 deletions eng/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}'
Expand Down
1 change: 1 addition & 0 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<Import Project="..\eng\TestVersions.props" />
<PropertyGroup>
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
<UseVSTestRunner>true</UseVSTestRunner>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion test/EndToEnd/ValidateInsertedManifests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void ManifestReaderCanReadManifests()
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");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public AndConstraint<CommandResultAssertions> ExitWith(int expectedExitCode)
public AndConstraint<CommandResultAssertions> 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<CommandResultAssertions>(this);
}

public AndConstraint<CommandResultAssertions> 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<CommandResultAssertions>(this);
}

Expand Down Expand Up @@ -125,7 +125,7 @@ public AndConstraint<CommandResultAssertions> HaveStdErrMatching(string pattern,
public AndConstraint<CommandResultAssertions> 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<CommandResultAssertions>(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public DirectoryInfoAssertions(DirectoryInfo dir)
public AndConstraint<DirectoryInfoAssertions> Exist()
{
Execute.Assertion.ForCondition(_dirInfo.Exists)
.FailWith("Expected directory {0} does not exist.", _dirInfo.FullName);
.FailWith(String.Format("Expected directory {0} does not exist.", _dirInfo.FullName));
return new AndConstraint<DirectoryInfoAssertions>(this);
}

Expand Down Expand Up @@ -71,7 +71,7 @@ public AndConstraint<DirectoryInfoAssertions> NotHaveFile(
Execute.Assertion
.ForCondition(file == null)
.BecauseOf(because, reasonArgs)
.FailWith("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<DirectoryInfoAssertions>(this);
}

Expand Down Expand Up @@ -109,8 +109,8 @@ public AndConstraint<DirectoryInfoAssertions> HaveFilesMatching(
Execute.Assertion
.ForCondition(matchingFileExists == true)
.BecauseOf(because, reasonArgs)
.FailWith("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<DirectoryInfoAssertions>(this);
}
Expand All @@ -132,16 +132,16 @@ public AndConstraint<DirectoryInfoAssertions> NotHaveFilesMatching(string expect
{
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.",
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<DirectoryInfoAssertions>(this);
}

public AndConstraint<DirectoryInfoAssertions> HaveDirectory(string expectedDir)
{
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);
.FailWith(String.Format("Expected directory {0} cannot be found inside directory {1}.", expectedDir, _dirInfo.FullName));

return new AndConstraint<DirectoryInfoAssertions>(new DirectoryInfoAssertions(dir));
}
Expand All @@ -160,7 +160,7 @@ public AndConstraint<DirectoryInfoAssertions> NotHaveDirectory(string unexpected
{
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);
.FailWith(String.Format("Directory {0} should not be found in directory {1}.", unexpectedDir, _dirInfo.FullName));

return new AndConstraint<DirectoryInfoAssertions>(new DirectoryInfoAssertions(dir));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="4.18.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="Microsoft.DotNet.Cli.Utils" Version="$(MicrosoftDotNetCliUtilsPackageVersion)" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
Expand Down
2 changes: 1 addition & 1 deletion test/core-sdk-tasks.Tests/core-sdk-tasks.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="4.18.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
</ItemGroup>

<ItemGroup>
Expand Down