Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: return status code 0 if pass after first failure #45 #48

Merged
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
7 changes: 7 additions & 0 deletions src/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [versionize](https://github.com/versionize/versionize) for commit guidelines.

<a name="1.3.1-alpha.0"></a>
## [1.3.1-alpha.0](https://github.com/joaoopereira/dotnet-test-rerun/releases/tag/v1.3.1-alpha.0) (2023-7-3)

### Bug Fixes

* return status code 0 if pass after first failure #45 ([4cb24ad](https://github.com/joaoopereira/dotnet-test-rerun/commit/4cb24ada8a212224f91a56c4b171489c22d377fa))

<a name="1.3.0-alpha.2"></a>
## [1.3.0-alpha.2](https://github.com/joaoopereira/dotnet-test-rerun/releases/tag/v1.3.0-alpha.2) (2023-7-2)

Expand Down
4 changes: 4 additions & 0 deletions src/DotNetTestRunner/DotNetTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ private void HandleProcessEnd()
throw new RerunException($"command:\ndotnet {ProcessStartInfo.Arguments}");
}
}
else
{
ErrorCode = ErrorCode.Success;
}
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/RerunCommand/RerunCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.CommandLine;
using System.IO.Abstractions;
using System.Text.RegularExpressions;
using dotnet.test.rerun.Analyzers;
using dotnet.test.rerun.DotNetTestRunner;
using dotnet.test.rerun.Enums;
Expand Down Expand Up @@ -66,6 +65,7 @@ public async Task Run()
oldTrxFile = trxFile;
if (string.IsNullOrEmpty(testsToRerun))
{
Environment.ExitCode = 0;
Log.Information($"Rerun attempt {attempt} not needed. All testes Passed.");
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/dotnet-test-rerun.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression> GPL-3.0-or-later</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<Version>1.3.0</Version>
<Version>1.3.1-alpha.0</Version>
<PackageProjectUrl>https://github.com/joaoopereira/dotnet-test-rerun</PackageProjectUrl>
<Description>wrapper of dotnet test command that automatic rerun failed tests</Description>
<RepositoryUrl>https://github.com/joaoopereira/dotnet-test-rerun</RepositoryUrl>
Expand Down
19 changes: 19 additions & 0 deletions test/dotnet-test-rerun.IntegrationTests/DotNetTestRerunTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,25 @@ public async Task DotnetTestRerun_FailingMultipleXUnit_Fails()
Exactly.Once());
Environment.ExitCode.Should().Be(1);
}

[Fact]
public async Task DotnetTestRerun_FailingNUnit_PassOnSecond()
{
// Arrange
Environment.ExitCode = 0;

// Act
var output = await RunDotNetTestRerunAndCollectOutputMessage("NUnitTestPassOnSecondRunExample");

// Assert
output.Should().Contain("Passed!");
output.Should().Contain("Failed!", Exactly.Times(1));
output.Should().Contain("Rerun filter: FullyQualifiedName~SecondSimpleNumberCompare",
Exactly.Once());
output.Should().Contain("Failed: 1, Passed: 1",
Exactly.Once());
Environment.ExitCode.Should().Be(0);
}

[Fact]
public async Task DotnetTestRerun_FailingXUnit_WithDeleteFiles()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace NUnitTestExample;

public class Tests
{
private int number = 2;

[Test, Order(1)]
public void SimpleNumberCompare()
{
number = 3;
Assert.AreEqual(3, number);
}

[Test, Order(2)]
public void SecondSimpleNumberCompare()
{
Assert.AreEqual(2, number);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using NUnit.Framework;