Skip to content

Commit

Permalink
Add ResultsFile Property to MSTestSettings
Browse files Browse the repository at this point in the history
Related issue: cake-build#730
  • Loading branch information
robertmuehsig committed Jul 13, 2016
1 parent cee3dd8 commit 7945eb2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Cake.Common.Tests/Unit/Tools/MSTest/MSTestRunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,19 @@ public void Should_Use_TestCategoryFilter_If_Provided()
Assert.Equal("\"/testcontainer:/Working/Test1.dll\" /category:\"!Network\" /noisolation", result.Args);
}

[Fact]
public void Should_Use_TestResultsFile_If_Provided()
{
//Given
var fixture = new MSTestRunnerFixture();
fixture.Settings.ResultsFile = @"c:\temp\myresults.trx";

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

Assert.Equal("\"/testcontainer:/Working/Test1.dll\" /resultsfile:\"c:\\temp\\myresults.trx\" /noisolation", result.Args);
}

[Fact]
public void Should_Not_Use_TestCategoryFilter_If_Not_Provided()
{
Expand Down
5 changes: 5 additions & 0 deletions src/Cake.Common/Tools/MSTest/MSTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ private ProcessArgumentBuilder GetArguments(IEnumerable<FilePath> assemblyPaths,
builder.Append(string.Concat("/category:", settings.Category.Quote()));
}

if (!string.IsNullOrEmpty(settings.ResultsFile))
{
builder.Append(string.Concat("/resultsfile:", settings.ResultsFile.Quote()));
}

if (settings.NoIsolation)
{
builder.Append("/noisolation");
Expand Down
6 changes: 6 additions & 0 deletions src/Cake.Common/Tools/MSTest/MSTestSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public sealed class MSTestSettings : ToolSettings
/// </summary>
public string Category { get; set; }

/// <summary>
/// Gets or sets the filepath for a named resulting test file.
/// MSTest.exe flag <see href="https://msdn.microsoft.com/en-us/library/ms182489.aspx#resultsfile">/resultsfile</see>.
/// </summary>
public string ResultsFile { get; set; }

/// <summary>
/// Gets or sets the test settings file to pass to MSTest.exe flag <see href="https://msdn.microsoft.com/en-us/library/ms182489.aspx#testsettings">/testsettings</see>.
/// </summary>
Expand Down

0 comments on commit 7945eb2

Please sign in to comment.