Skip to content

Commit

Permalink
Added support for xUnit 'Environment' parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbra committed Apr 22, 2024
1 parent 929d000 commit d2853f9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion smink.UnitTests/RunXUnitTestsFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class RunXUnitTestsFixture: IAsyncLifetime
public Assemblies? Assemblies { get; set; }
public TestReport? TestReport { get; set; }

public string Environment { get; } = "Environment name specified on the command line";

private readonly string _testResultsFilePattern;
private readonly XUnitResultsReader _xunit;
private readonly XUnitResultsAdapter _xUnitResultsAdapter;
Expand Down Expand Up @@ -71,7 +73,7 @@ private async Task RunXunitTests()
"test",
"-verbosity:q",
"-maxcpucount:1",
$"--logger:xunit;LogFilePath={_testResultsFilePattern}"
$"--logger:xunit;LogFilePath={_testResultsFilePattern};Environment={Environment}"
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public TestSuite_(RunXUnitTestsFixture fixture)
[Fact]
public void Has_correct_Name() => _testSuite!.Name.Should().Be("Adding_a_new_customer");

[Fact]
public void Has_correct_Environment() => _testSuite!.Environment.Should().Be("Environment name specified on the command line");

[Fact]
public void Has_correct_DisplayName() => _testSuite!.DisplayName.Should().Be("Adding a new customer");

Expand Down
2 changes: 1 addition & 1 deletion smink/Templates/DefaultTestReportTemplate.razor
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
<details class="suite">
<summary>
<h2 class="summaryHeading">
@suite.DisplayName
@(!string.IsNullOrWhiteSpace(suite.Environment) ? $"{suite.Environment}: " : "")@suite.DisplayName
</h2>
<!-- Time Label -->
<div class="ui blue label" data-tooltip="Test suite runtime" style="float:right;">
Expand Down
2 changes: 1 addition & 1 deletion smink/TestResultAdapters/XUnitResultsAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private static TestSuite GetTestSuite(Assembly arg, string rootNamespace, Collec

DateTime runDateAndTime = runDate.ToDateTime(runTime);

return new TestSuite
return new TestSuite
{
Id = (arg.Id ?? Guid.NewGuid()).ToString(),
Name = testSuiteName,
Expand Down

0 comments on commit d2853f9

Please sign in to comment.