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

GH-3127: Add ResultsDirectory to VSTestSettings. (see #3127) #3128

Merged
merged 1 commit into from
Feb 16, 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
14 changes: 14 additions & 0 deletions src/Cake.Common.Tests/Unit/Tools/VSTest/VSTestRunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,20 @@ public void Should_Use_Diag_If_Provided()
Assert.Equal("\"/Working/Test1.dll\" /Diag:\"/Working/Path to/diag log.txt\"", result.Args);
}

[Fact]
public void Should_Use_ResultsDirectory_If_Provided()
{
// Given
var fixture = new VSTestRunnerFixture();
fixture.Settings.ResultsDirectory = new DirectoryPath("./Path to/");

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

// Then
Assert.Equal("\"/Working/Test1.dll\" /ResultsDirectory:\"/Working/Path to\"", result.Args);
}

[Fact]
public void Should_Use_SettingsFile_If_Provided()
{
Expand Down
5 changes: 5 additions & 0 deletions src/Cake.Common/Tools/VSTest/VSTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ private ProcessArgumentBuilder GetArguments(IEnumerable<FilePath> assemblyPaths,
builder.AppendSwitchQuoted("/Diag", ":", settings.Diag.MakeAbsolute(_environment).FullPath);
}

if (settings.ResultsDirectory != null)
{
builder.AppendSwitchQuoted("/ResultsDirectory", ":", settings.ResultsDirectory.MakeAbsolute(_environment).FullPath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good / prior art

}

if (!string.IsNullOrEmpty(settings.Logger))
{
builder.Append("/Logger:{0}", settings.Logger.Trim());
Expand Down
7 changes: 7 additions & 0 deletions src/Cake.Common/Tools/VSTest/VSTestSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ public sealed class VSTestSettings : ToolSettings
/// </summary>
public FilePath Diag { get; set; }

/// <summary>
/// Gets or sets the result directory.
/// Test results directory will be created in specified path if not exists.
/// VSTest.Console.exe flag <see href="https://docs.microsoft.com/en-us/visualstudio/test/vstest-console-options#ResultDirectory">/ResultsDirectory</see>.
/// </summary>
public DirectoryPath ResultsDirectory { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Matches command-line argument in VSTest-Console docs

image


/// <summary>
/// Gets or sets the name of your logger. Possible values:
/// - A blank string (or null): no logger
Expand Down