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

fix: solve issues in verbosity normal #157

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Context
TBD

## Description
TBD

## Changes in the codebase
TBD

## Associated Issues
No issue associated
11 changes: 9 additions & 2 deletions src/DotNetRunner/DotNetTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void HandleProcessEnd()
ErrorCode = ErrorCode.WellKnownError;
Log.Warning(ProcessExecution.GetError());
}
else if (HaveFailedTests())
else if (HaveFailedTests() || HaveSimpleFailedTests())
{
ErrorCode = ErrorCode.FailedTests;
}
Expand Down Expand Up @@ -102,5 +102,12 @@ private void HandleProcessEnd()
/// </summary>
/// <returns></returns>
private bool HaveFailedTests() => ExitCode == 1 &&
(ProcessExecution.GetOutput().Contains("Failed! - Failed:"));
ProcessExecution.GetOutput().Contains("Failed! - Failed:");

/// <summary>
/// Check if the output of dotnet test have in the last line failed tests
/// </summary>
/// <returns></returns>
private bool HaveSimpleFailedTests() => ExitCode == 1 &&
ProcessExecution.GetOutput().Contains("Failed:");
}
30 changes: 30 additions & 0 deletions test/dotnet-test-rerun.IntegrationTests/DotNetTestRerunTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,36 @@ public async Task DotnetTestRerun_FailingXUnit_Fails()
Environment.ExitCode.Should().Be(1);
}

[InlineData("normal")]
[InlineData("quiet")]
[InlineData("minimal")]
[InlineData("detailed")]
[InlineData("diagnostic")]
public async Task DotnetTestRerun_FailingXUnit_WithVerbosity_Fails(string verbosity)
{
// Arrange
Environment.ExitCode = 0;

// Arrange
var testDir = TestUtilities.GetTmpDirectory();
TestUtilities.CopyFixture(string.Empty, new DirectoryInfo(testDir));
Environment.ExitCode = 0;

// Act
var output = await RunDotNetTestRerunAndCollectOutputMessage("FailingXUnitExample", dir: testDir, extraArgs: $"--verbosity {verbosity}");

// Assert
output.Should().NotContain("Passed!");
output.Should().Contain("Failed:", Exactly.Times(4));
output.Should().Contain("Rerun filter: FullyQualifiedName~FailingXUnitExample.SimpleTest.SimpleStringCompare",
Exactly.Thrice());
output.Should().Contain("Passed: 4",
Exactly.Once());
var files = FileSystem.Directory.EnumerateFiles(testDir, "*trx");
files.Should().HaveCount(4);
Environment.ExitCode.Should().Be(1);
}

[Fact]
public async Task DotnetTestRerun_FailingXUnit_WithMultipleFrameworks_Fails()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Spectre.Console" Version="0.49.1" />
<PackageReference Include="Spectre.Console.Testing" Version="0.48.0" />
<PackageReference Include="Spectre.Console.Testing" Version="0.49.1" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="Spectre.Console.Testing" Version="0.48.0" />
<PackageReference Include="Spectre.Console.Testing" Version="0.49.1" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Loading