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: Allow MergeCoverageFormat to default to null #86

Merged
merged 2 commits into from
Oct 8, 2023
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
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);
}

}