Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Commit

Permalink
Issue #7
Browse files Browse the repository at this point in the history
  • Loading branch information
kharnagy committed Feb 28, 2014
1 parent 513ef47 commit b1d4ac5
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 7 deletions.
1 change: 1 addition & 0 deletions NUnit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="NUnitAppAction.cs" />
<Compile Include="NUnitConfigurer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
9 changes: 5 additions & 4 deletions NUnitActionEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ protected override void CreateChildControls()

this.txtExePath = new SourceControlFileFolderPicker
{
Required = true,
DisplayMode = SourceControlBrowser.DisplayModes.FoldersAndFiles,
ServerId = this.ServerId
ServerId = this.ServerId,
DefaultText = "Default for Selected Configuration"
};

this.txtGroupName = new ValidatingTextBox
Expand Down Expand Up @@ -90,8 +90,9 @@ protected override void CreateChildControls()

this.Controls.Add(
new FormFieldGroup(
"NUnit Executable Path",
"The path to (and including) nunit-console.exe.",
"Custom NUnit Executable Path",
"The path to (and including) nunit-console.exe if using a different version of NUnit than the one specified "
+"in the NUnit extension configuration.",
false,
new StandardFormField("NUnit Exe Path:", this.txtExePath)
),
Expand Down
18 changes: 15 additions & 3 deletions NUnitAppAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ protected override void RunTests()
var agent = this.Context.Agent;
{
var fileOps = agent.GetService<IFileOperationsExecuter>();
var nunitPath = fileOps.GetWorkingDirectory(this.Context.ApplicationId, this.Context.DeployableId ?? 0, this.ExePath);

var tmpFileName = this.GetXmlOutputPath(fileOps);
string nunitExePath = this.GetNUnitExePath(fileOps);
string tmpFileName = this.GetXmlOutputPath(fileOps);

this.ExecuteCommandLine(
nunitPath,
nunitExePath,
string.Format("\"{0}\" /xml:\"{1}\" {2}", this.TestFile, tmpFileName, this.AdditionalArguments),
this.Context.SourceDirectory
);
Expand Down Expand Up @@ -144,6 +144,18 @@ protected override void RunTests()
}
}

private string GetNUnitExePath(IFileOperationsExecuter fileOps)
{
if (!string.IsNullOrWhiteSpace(this.ExePath))
return fileOps.GetWorkingDirectory(this.Context.ApplicationId, this.Context.DeployableId ?? 0, this.ExePath);

var configurer = (NUnitConfigurer)this.GetExtensionConfigurer();
if (string.IsNullOrWhiteSpace(configurer.NUnitConsoleExePath))
throw new InvalidOperationException("The path to NUnit was not specified in either the action or the selected NUnit extension's configuration.");

return fileOps.GetWorkingDirectory(this.Context.ApplicationId, this.Context.DeployableId ?? 0, configurer.NUnitConsoleExePath);
}

private string GetXmlOutputPath(IFileOperationsExecuter fileOps)
{
if (string.IsNullOrWhiteSpace(this.CustomXmlOutputPath))
Expand Down
38 changes: 38 additions & 0 deletions NUnitConfigurer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.ComponentModel;
using Inedo.BuildMaster;
using Inedo.BuildMaster.Extensibility.Configurers.Extension;

[assembly: ExtensionConfigurer(typeof(Inedo.BuildMasterExtensions.NUnit.NUnitConfigurer))]

namespace Inedo.BuildMasterExtensions.NUnit
{
public sealed class NUnitConfigurer : ExtensionConfigurerBase
{
/// <summary>
/// Initializes a new instance of the <see cref="NUnitConfigurer"/> class.
/// </summary>
public NUnitConfigurer()
{
}

/// <summary>
/// Gets or sets the path to nunit-console.exe.
/// </summary>
[Persistent]
[DisplayName("NUnit Console Executable Path")]
[Description(@"The path to nunit-console.exe, typically: <br /><br />"
+ @"""C:\Program Files (x86)\NUnit 2.X.X\bin\nunit-console.exe")]
public string NUnitConsoleExePath { get; set; }

/// <summary>
/// Returns a <see cref="System.String" /> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="System.String" /> that represents this instance.
/// </returns>
public override string ToString()
{
return string.Empty;
}
}
}

0 comments on commit b1d4ac5

Please sign in to comment.