Skip to content

Commit

Permalink
Allow setting /testsettings: file for MSTest runner cake-build#421
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosnz committed Nov 18, 2015
1 parent 6648f44 commit 4bbb99a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Cake.Common.Tests/Unit/Tools/MSTest/MSTestRunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,19 @@ public void Should_Use_Isolation_If_Disabled_In_Settings()
// Then
Assert.Equal("\"/testcontainer:/Working/Test1.dll\"", result.Args);
}

[Fact]
public void Should_Use_Test_Settings_File_If_Set()
{
// Given
var fixture = new MSTestRunnerFixture();
fixture.Settings.TestSettingsFile = "my.testsettings";

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

// Then
Assert.Equal("\"/testcontainer:/Working/Test1.dll\" \"/noisolation\" /testsettings:my.testsettings", result.Args);
}
}
}
13 changes: 13 additions & 0 deletions src/Cake.Common/Tools/MSTest/MSTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ private ProcessArgumentBuilder GetArguments(FilePath assemblyPath, MSTestSetting
builder.AppendQuoted("/noisolation");
}

// Got a specific test settings file?
if (!string.IsNullOrWhiteSpace(settings.TestSettingsFile))
{
// Add the file as a property.
var testSettingsFile = settings.TestSettingsFile.Trim();
if (testSettingsFile.Contains(" "))
{
testSettingsFile = testSettingsFile.Quote();
}

builder.Append(string.Concat("/testsettings:", testSettingsFile));
}

return builder;
}

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 @@ -18,6 +18,12 @@ public sealed class MSTestSettings : ToolSettings
/// </value>
public bool NoIsolation { get; set; }

/// <summary>
/// Gets or sets the test settings file. If set, it is be passed to MSBuild e.g. /testsettings:local.Testsettings
/// </summary>
/// <value>The test settings file.</value>
public string TestSettingsFile { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="MSTestSettings"/> class.
/// </summary>
Expand Down

0 comments on commit 4bbb99a

Please sign in to comment.