diff --git a/src/Cake.Common.Tests/Unit/Tools/MSTest/MSTestRunnerTests.cs b/src/Cake.Common.Tests/Unit/Tools/MSTest/MSTestRunnerTests.cs index d08be50018..97f9319b78 100644 --- a/src/Cake.Common.Tests/Unit/Tools/MSTest/MSTestRunnerTests.cs +++ b/src/Cake.Common.Tests/Unit/Tools/MSTest/MSTestRunnerTests.cs @@ -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() { diff --git a/src/Cake.Common/Tools/MSTest/MSTestRunner.cs b/src/Cake.Common/Tools/MSTest/MSTestRunner.cs index 2cd660a8f8..92f6cd5459 100644 --- a/src/Cake.Common/Tools/MSTest/MSTestRunner.cs +++ b/src/Cake.Common/Tools/MSTest/MSTestRunner.cs @@ -69,6 +69,11 @@ private ProcessArgumentBuilder GetArguments(IEnumerable 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"); diff --git a/src/Cake.Common/Tools/MSTest/MSTestSettings.cs b/src/Cake.Common/Tools/MSTest/MSTestSettings.cs index ff7c1ec324..ec8f58179b 100644 --- a/src/Cake.Common/Tools/MSTest/MSTestSettings.cs +++ b/src/Cake.Common/Tools/MSTest/MSTestSettings.cs @@ -28,6 +28,12 @@ public sealed class MSTestSettings : ToolSettings /// public string Category { get; set; } + /// + /// Gets or sets the filepath for a named resulting test file. + /// MSTest.exe flag /resultsfile. + /// + public string ResultsFile { get; set; } + /// /// Gets or sets the test settings file to pass to MSTest.exe flag /testsettings. ///