Skip to content

Commit

Permalink
Add ResultsDirectory to VSTestSettings. (see cake-build#3127)
Browse files Browse the repository at this point in the history
  • Loading branch information
soroshsabz committed Feb 16, 2021
1 parent bfb0cb4 commit 1d6e467
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
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);
}

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; }

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

0 comments on commit 1d6e467

Please sign in to comment.