Skip to content

Commit

Permalink
fix: Allow MergeCoverageFormat to default to null
Browse files Browse the repository at this point in the history
  • Loading branch information
dima-ringba authored and ricardofslp committed Oct 8, 2023
1 parent 18a7240 commit 6bfda1d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/RerunCommand/RerunCommandConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public class RerunCommandConfiguration
IsRequired = false
};

private readonly Option<CoverageFormat> MergeCoverageFormatOption =
private readonly Option<CoverageFormat?> MergeCoverageFormatOption =
new(new[] { "--mergeCoverageFormat" })
{
Description =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.CommandLine;
using System.CommandLine.Invocation;
using System.CommandLine.Parsing;
using dotnet.test.rerun.Enums;
using dotnet.test.rerun.Logging;
using dotnet.test.rerun.RerunCommand;
using FluentAssertions;
Expand Down Expand Up @@ -80,6 +81,7 @@ public void RerunCommandConfiguration_GetValues_ShouldGetDefaultValues()
_configuration.Delay.Should().Be(0);
_configuration.Verbosity.Should().BeNull();
_configuration.Configuration.Should().BeNull();
_configuration.MergeCoverageFormat.Should().BeNull();
}

[Fact]
Expand Down Expand Up @@ -181,4 +183,32 @@ public void RerunCommandConfiguration_AppendFailedTests_WithNoriginalFilter()
//Assert
failedTests.Should().Be(firstTest);
}

[Theory]
[InlineData("", null)]
[InlineData("Coverage", CoverageFormat.Coverage)]
[InlineData("Xml", CoverageFormat.Xml)]
[InlineData("Cobertura", CoverageFormat.Cobertura)]
[InlineData("coverage", CoverageFormat.Coverage)]
[InlineData("xml", CoverageFormat.Xml)]
[InlineData("cobertura", CoverageFormat.Cobertura)]
public void RerunCommandConfiguration_GetValues_MergeCoverageFormat(string formatArg, CoverageFormat? expected)
{
if(!string.IsNullOrWhiteSpace(formatArg) )
{
formatArg = "--mergeCoverageFormat " + formatArg;
}

//Arrange
_configuration.Set(Command);
var result = new Parser(Command).Parse($"path {formatArg}");
var context = new InvocationContext(result);

//Act
_configuration.GetValues(context);

//Assert
_configuration.MergeCoverageFormat.Should().Be(expected);
}

}

0 comments on commit 6bfda1d

Please sign in to comment.