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

Add dotnet test --blame Flag to DotNetCoreTestSettings #2936

Merged
merged 1 commit into from
Feb 13, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,13 @@ public void Should_Add_Additional_Settings()
fixture.Settings.ResultsDirectory = "./tests/";
fixture.Settings.VSTestReportPath = "./tests/TestResults.xml";
fixture.Settings.Runtime = "win-x64";
fixture.Settings.Blame = true;

// When
var result = fixture.Run();

// Then
Assert.Equal("test --settings \"/Working/demo.runsettings\" --filter \"Priority = 1\" --test-adapter-path \"/Working/custom-test-adapter\" --logger \"trx;LogFileName=/Working/logfile.trx\" --logger \"html;LogFileName=/Working/logfile.html\" --output \"/Working/artifacts\" --framework dnxcore50 --configuration Release --collect \"XPlat Code Coverage\" --diag \"/Working/artifacts/logging/diagnostics.txt\" --no-build --no-restore --nologo --results-directory \"/Working/tests\" --logger trx;LogFileName=\"/Working/tests/TestResults.xml\" --runtime win-x64", result.Args);
Assert.Equal("test --settings \"/Working/demo.runsettings\" --filter \"Priority = 1\" --test-adapter-path \"/Working/custom-test-adapter\" --logger \"trx;LogFileName=/Working/logfile.trx\" --logger \"html;LogFileName=/Working/logfile.html\" --output \"/Working/artifacts\" --framework dnxcore50 --configuration Release --collect \"XPlat Code Coverage\" --diag \"/Working/artifacts/logging/diagnostics.txt\" --no-build --no-restore --nologo --results-directory \"/Working/tests\" --logger trx;LogFileName=\"/Working/tests/TestResults.xml\" --runtime win-x64 --blame", result.Args);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,11 @@ public sealed class DotNetCoreTestSettings : DotNetCoreSettings
/// Gets or sets the target runtime to test for. This setting is only available from .NET Core 3.x upward.
/// </summary>
public string Runtime { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to run the tests in blame mode. This option is helpful in isolating a problematic test causing the test host to crash.
/// Outputs a 'Sequence.xml' file in the current directory that captures the order of execution of test before the crash.
/// </summary>
public bool Blame { get; set; }
}
}
6 changes: 6 additions & 0 deletions src/Cake.Common/Tools/DotNetCore/Test/DotNetCoreTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ private ProcessArgumentBuilder GetArguments(string project, ProcessArgumentBuild
builder.Append(settings.Runtime);
}

// Blame
if (settings.Blame)
{
builder.Append("--blame");
}

if (!arguments.IsNullOrEmpty())
{
builder.Append("--");
Expand Down