Skip to content

Commit

Permalink
GH-2297 - Extended NUnit3Settings to support alternative app.config f…
Browse files Browse the repository at this point in the history
…iles

- Modified NUnit3Settings class to support new ConfigurationFile property that maps to --configfile=app.config for the nunit-console runner
- In the 3.8.0 release of the nunit-console runner, a new command line argument was added that supports loading the app.config file from an alternative path or file.
- Here is the new 3.8.0 feature: nunit/nunit-console#246
  • Loading branch information
Josiah Peters committed Sep 25, 2018
1 parent 57914c4 commit eab5df1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Cake.Common.Tests/Unit/Tools/NUnit/NUnit3RunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public void Should_Set_Commandline_Switches()
fixture.Settings.ShadowCopy = true;
fixture.Settings.Agents = 3;
fixture.Settings.TraceLevel = NUnitInternalTraceLevel.Debug;
fixture.Settings.ConfigurationFile = "app.config";
fixture.Settings.Params = new Dictionary<string, string>
{
["one"] = "1",
Expand All @@ -266,6 +267,7 @@ public void Should_Set_Commandline_Switches()
"--dispose-runners --shadowcopy --agents=3 " +
"--process=InProcess --domain=Single " +
"--trace=verbose " +
"\"--configfile=/Working/app.config\" " +
"\"--params=one=1\" " +
"\"--params=two=2\" " +
"\"--params=three=3\"", result.Args);
Expand Down
5 changes: 5 additions & 0 deletions src/Cake.Common/Tools/NUnit/NUnit3Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,11 @@ private ProcessArgumentBuilder GetArguments(IEnumerable<FilePath> assemblyPaths,
builder.Append("--trace=" + settings.TraceLevel.Value.GetArgumentValue());
}

if (settings.ConfigurationFile != null)
{
builder.AppendQuoted(string.Format(CultureInfo.InvariantCulture, "--configfile={0}", settings.ConfigurationFile.MakeAbsolute(_environment).FullPath));
}

if (settings.Params != null && settings.Params.Count > 0)
{
foreach (var param in settings.Params)
Expand Down
6 changes: 6 additions & 0 deletions src/Cake.Common/Tools/NUnit/NUnit3Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ public sealed class NUnit3Settings : ToolSettings
/// </value>
public int? Agents { get; set; }

/// <summary>
/// Gets or sets a value indicating the path to an alternative app.config file to load.
/// </summary>
/// <value>The location that NUnit should load an alternative app.config file from.</value>
public FilePath ConfigurationFile { get; set; }

/// <summary>
/// Gets or sets the parameters that should be passed to the runner.
/// </summary>
Expand Down

0 comments on commit eab5df1

Please sign in to comment.