Browse Source

Added support for running unit tests against .NET 1.1 when the project is being built against this framework. Fixed SD2-1232 - the temporary test results file is now deleted after a test run has finished.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2135 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 19 years ago
parent
commit
e3e638b550
  1. 8
      src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs
  2. 1
      src/AddIns/Misc/UnitTesting/Src/TestResultsMonitor.cs
  3. 53
      src/AddIns/Misc/UnitTesting/Src/UnitTestApplicationStartHelper.cs
  4. 38
      src/AddIns/Misc/UnitTesting/Test/UnitTestCommandLineTests.cs
  5. 19
      src/Setup/Files.wxs
  6. 4
      src/Setup/Setup.wxs
  7. 7
      src/Tools/Tools.build

8
src/AddIns/Misc/UnitTesting/Src/RunTestCommands.cs

@ -129,6 +129,7 @@ namespace ICSharpCode.UnitTesting @@ -129,6 +129,7 @@ namespace ICSharpCode.UnitTesting
// Read the rest of the file just in case.
testResultsMonitor.Stop();
testResultsMonitor.Read();
StopMonitoring();
projects.Remove(currentProject);
if (projects.Count > 0) {
@ -410,7 +411,7 @@ namespace ICSharpCode.UnitTesting @@ -410,7 +411,7 @@ namespace ICSharpCode.UnitTesting
protected override void RunTests(UnitTestApplicationStartHelper helper)
{
TestRunnerCategory.AppendLine(helper.GetCommandLine());
runner.Start(UnitTestApplicationStartHelper.UnitTestConsoleApplication, helper.GetArguments());
runner.Start(helper.GetUnitTestConsoleApplication(), helper.GetArguments());
}
protected override void OnStop()
@ -418,6 +419,11 @@ namespace ICSharpCode.UnitTesting @@ -418,6 +419,11 @@ namespace ICSharpCode.UnitTesting
runner.Kill();
}
protected ProcessRunner GetProcessRunner()
{
return runner;
}
void OutputLineReceived(object source, LineReceivedEventArgs e)
{
TestRunnerCategory.AppendLine(e.Line);

1
src/AddIns/Misc/UnitTesting/Src/TestResultsMonitor.cs

@ -96,7 +96,6 @@ namespace ICSharpCode.UnitTesting @@ -96,7 +96,6 @@ namespace ICSharpCode.UnitTesting
{
string text = ReadTextAdded();
if (text != null) {
Console.WriteLine(text);
TestResult[] results = testResultsReader.Read(text);
OnTestResultsReceived(results);
}

53
src/AddIns/Misc/UnitTesting/Src/UnitTestApplicationStartHelper.cs

@ -23,6 +23,8 @@ namespace ICSharpCode.UnitTesting @@ -23,6 +23,8 @@ namespace ICSharpCode.UnitTesting
/// </summary>
public class UnitTestApplicationStartHelper
{
public const string TargetFrameworkVersionNet11 = "v1.1";
/// <summary>
/// returns full/path/to/Tools/NUnit
/// </summary>
@ -32,6 +34,15 @@ namespace ICSharpCode.UnitTesting @@ -32,6 +34,15 @@ namespace ICSharpCode.UnitTesting
}
}
/// <summary>
/// returns full/path/to/Tools/NUnit that runs under .NET 1.1.
/// </summary>
public static string UnitTestApplicationDirectoryNet11 {
get {
return Path.Combine(UnitTestApplicationDirectory, "Net-1.1");
}
}
/// <summary>
/// returns full/path/to/Tools/NUnit/nunit-console.exe
/// </summary>
@ -41,6 +52,15 @@ namespace ICSharpCode.UnitTesting @@ -41,6 +52,15 @@ namespace ICSharpCode.UnitTesting
}
}
/// <summary>
/// returns full/path/to/Tools/NUnit/nunit-console.exe that runs under .NET 1.1.
/// </summary>
public static string UnitTestConsoleApplicationNet11 {
get {
return Path.Combine(UnitTestApplicationDirectoryNet11, "nunit-console.exe");
}
}
public readonly List<string> Assemblies = new List<string>();
/// <summary>
@ -117,6 +137,37 @@ namespace ICSharpCode.UnitTesting @@ -117,6 +137,37 @@ namespace ICSharpCode.UnitTesting
}
}
/// <summary>
/// Gets the Unit Test console application filename based on the
/// target framework specified in the project.
/// </summary>
/// <remarks>Deliberately using the unevaluated property since the
/// SharpDevelop build targets file changes the target version to
/// v1.0 if it is v1.1.</remarks>
public static string GetUnitTestConsoleApplication(string targetFrameworkVersion)
{
switch (targetFrameworkVersion) {
case TargetFrameworkVersionNet11:
return UnitTestConsoleApplicationNet11;
default:
return UnitTestConsoleApplication;
}
}
/// <summary>
/// Gets the Unit Test console application filename based on the
/// target framework specified in the project.
/// </summary>
/// <remarks>Deliberately using the unevaluated property since the
/// SharpDevelop build targets file changes the target version to
/// v1.0 if it is v1.1.</remarks>
public string GetUnitTestConsoleApplication()
{
MSBuildBasedProject msbuildBasedProject = (MSBuildBasedProject)project;
string targetFrameworkVersion = msbuildBasedProject.GetUnevalatedProperty("TargetFrameworkVersion");
return GetUnitTestConsoleApplication(targetFrameworkVersion);
}
/// <summary>
/// Gets the full command line to run the unit test application.
/// This is the combination of the UnitTestConsoleApplication and
@ -124,7 +175,7 @@ namespace ICSharpCode.UnitTesting @@ -124,7 +175,7 @@ namespace ICSharpCode.UnitTesting
/// </summary>
public string GetCommandLine()
{
return String.Concat("\"", UnitTestConsoleApplication, "\" ", GetArguments());
return String.Concat("\"", GetUnitTestConsoleApplication(), "\" ", GetArguments());
}
/// <summary>

38
src/AddIns/Misc/UnitTesting/Test/UnitTestCommandLineTests.cs

@ -174,5 +174,43 @@ namespace UnitTesting.Tests @@ -174,5 +174,43 @@ namespace UnitTesting.Tests
helper.Initialize(project, null, null);
Assert.AreSame(project, helper.Project);
}
/// <summary>
/// Here the project specifies that it is to be compiled
/// against the .NET 1.1 framework so for testing we use the
/// nunit-console.exe that runs against that framework.
/// </summary>
[Test]
public void Netv11TargetFramework()
{
project.SetProperty("TargetFrameworkVersion", "v1.1");
helper.Initialize(project, null, null);
helper.ShadowCopy = true;
FileUtility.ApplicationRootPath = @"C:\SharpDevelop";
string expectedFullCommandLine = "\"C:\\SharpDevelop\\bin\\Tools\\NUnit\\Net-1.1\\nunit-console.exe\" \"C:\\Projects\\MyTests\\MyTests.dll\"";
Assert.AreEqual(expectedFullCommandLine, helper.GetCommandLine());
}
/// <summary>
/// Here the project specifies that it is to be compiled
/// against the .NET 1.0 framework. We do not support .NET 1.0
/// so we return the nunit-console that runs against .NET 2.0.
/// </summary>
[Test]
public void Netv10TargetFramework()
{
project.SetProperty("TargetFrameworkVersion", "v1.0");
helper.Initialize(project, null, null);
helper.ShadowCopy = true;
FileUtility.ApplicationRootPath = @"C:\SharpDevelop";
string expectedFullCommandLine = "\"C:\\SharpDevelop\\bin\\Tools\\NUnit\\nunit-console.exe\" \"C:\\Projects\\MyTests\\MyTests.dll\"";
Assert.AreEqual(expectedFullCommandLine, helper.GetCommandLine());
}
}
}

19
src/Setup/Files.wxs

@ -414,6 +414,21 @@ @@ -414,6 +414,21 @@
<File Source="..\..\bin\Tools\NUnit\nunit.framework.dll" Name="nuframg.dll" Id="nunit.framework.gac.dll" LongName="nunit.framework.dll" Assembly=".net" AssemblyManifest="nunit.framework.gac.dll" KeyPath="yes" />
</Component>
</Directory>
<Directory Id="Net_1.1" Name="Net-1.1">
<Component Guid="68CCA177-12B4-4EDE-9912-D60845D8CC06" Id="NUnitConsoleRunnerDllNetv11" DiskId="1">
<File Source="..\..\bin\Tools\NUnit\Net-1.1\nunit-console-runner.dll" Name="nucrun2.dll" Id="Net_1.1.nunit_console_runner.dll" LongName="nunit-console-runner.dll" AssemblyApplication="Net_1.1.nunit_console_runner.dll" AssemblyManifest="Net_1.1.nunit_console_runner.dll" Assembly=".net" KeyPath="yes" />
</Component>
<Component Guid="5B5D5C28-416C-4EF1-9476-CD120A1AC1B0" Id="NUnitConsoleNetv11Files" DiskId="1">
<File Source="..\..\bin\Tools\NUnit\Net-1.1\nunit-console.exe" Name="nucons2.exe" Id="Net_1.1.nunit_console.exe" LongName="nunit-console.exe" AssemblyApplication="Net_1.1.nunit_console.exe" AssemblyManifest="Net_1.1.nunit_console.exe" Assembly=".net" KeyPath="yes" />
<File Source="..\..\bin\Tools\NUnit\Net-1.1\nunit-console.exe.config" Name="nucons2.con" Id="Net_1.1.nunit_console.exe1.config" LongName="nunit-console.exe.config" />
</Component>
<Component Guid="1615EFF3-D86A-4F7E-A1C7-4417EB420002" Id="NUnitCoreDllNetv11" DiskId="1">
<File Source="..\..\bin\Tools\NUnit\Net-1.1\nunit.core.dll" Name="nucore2.dll" Id="Net_1.1.nunit.core.dll" LongName="nunit.core.dll" Assembly=".net" AssemblyApplication="Net_1.1.nunit.core.dll" AssemblyManifest="Net_1.1.nunit.core.dll" KeyPath="yes" />
</Component>
<Component Guid="3D66D8B1-5C03-404B-882B-105715A598CD" Id="NUnitUtilDllNetv11" DiskId="1">
<File Source="..\..\bin\Tools\NUnit\Net-1.1\nunit.util.dll" Name="nuutil2.dll" Id="Net_1.1.nunit.util.dll" LongName="nunit.util.dll" Assembly=".net" AssemblyApplication="Net_1.1.nunit.util.dll" AssemblyManifest="Net_1.1.nunit.util.dll" KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
@ -650,8 +665,8 @@ @@ -650,8 +665,8 @@
</Component>
<Component Guid="3ffcfcc0-6f9b-11db-9fe1-0800200c9a66" Id="CSharpConfigurationFileTemplates" DiskId="1">
<File Source="..\..\data\templates\file\CSharp\CSharp.ConfigurationElement.xft" Name="CSCONFIG.XFT" Id="CSharp.ConfigurationElement.xft" LongName="CSharp.ConfigurationElement.xft" />
<File Source="..\..\data\templates\file\CSharp\CSharp.ConfigurationElementCollection.xft" Name="CSCONFIG.XFT" Id="CSharp.ConfigurationElementCollection.xft" LongName="CSharp.ConfigurationElementCollection.xft" />
<File Source="..\..\data\templates\file\CSharp\CSharp.ConfigurationSection.xft" Name="CSCONFIG.XFT" Id="CSharp.ConfigurationSection.xft" LongName="CSharp.ConfigurationSection.xft" />
<File Source="..\..\data\templates\file\CSharp\CSharp.ConfigurationElementCollection.xft" Name="CSCONCOL.XFT" Id="CSharp.ConfigurationElementCollection.xft" LongName="CSharp.ConfigurationElementCollection.xft" />
<File Source="..\..\data\templates\file\CSharp\CSharp.ConfigurationSection.xft" Name="CSCONSEC.XFT" Id="CSharp.ConfigurationSection.xft" LongName="CSharp.ConfigurationSection.xft" />
<File Source="..\..\data\templates\file\CSharp\ConfigurationElement.cs" Name="CONFELEM.CS" Id="ConfigurationElement.cs" LongName="ConfigurationElement.cs" />
<File Source="..\..\data\templates\file\CSharp\ConfigurationElementCollection.cs" Name="CONFECOL.CS" Id="ConfigurationElementCollection.cs" LongName="ConfigurationElementCollection.cs" />
<File Source="..\..\data\templates\file\CSharp\ConfigurationSection.cs" Name="CONFSECT.CS" Id="ConfigurationSection.cs" LongName="ConfigurationSection.cs" />

4
src/Setup/Setup.wxs

@ -210,6 +210,10 @@ @@ -210,6 +210,10 @@
<ComponentRef Id="NUnitCoreGacDll"/>
<ComponentRef Id="NUnitFrameworkGacDll"/>
<ComponentRef Id="NunitConsoleRunnerDll"/>
<ComponentRef Id="NUnitUtilDllNetv11"/>
<ComponentRef Id="NUnitConsoleNetv11Files"/>
<ComponentRef Id="NUnitCoreDllNetv11"/>
<ComponentRef Id="NUnitConsoleRunnerDllNetv11"/>
<ComponentRef Id="ConversionStyleSheetFiles"/>
<ComponentRef Id="TextLibOptionsFiles"/>
<ComponentRef Id="OptionsFiles"/>

7
src/Tools/Tools.build

@ -6,7 +6,9 @@ @@ -6,7 +6,9 @@
<WixDocFiles Include="wix\doc\*"/>
<WixLibFiles Include="wix\lib\*"/>
<WixIncFiles Include="wix\inc\*"/>
<NUnitFiles Include="NUnit\*"/>
<NUnitFiles Include="NUnit\*.dll;NUnit\*.exe"/>
<NUnitConfigFileNetv11 Include="NUnit\nunit-console-netv11.exe.config"/>
<NUnitConfigFile Include="NUnit\nunit-console.exe.config"/>
<HelpToolFiles Include="Help\*"/>
</ItemGroup>
@ -18,6 +20,9 @@ @@ -18,6 +20,9 @@
<Copy SourceFiles="@(WixIncFiles)" DestinationFolder="..\..\bin\Tools\Wix\inc"/>
<Copy SourceFiles="@(WixLibFiles)" DestinationFolder="..\..\bin\Tools\Wix\lib"/>
<Copy SourceFiles="@(NUnitFiles)" DestinationFolder="..\..\bin\Tools\NUnit"/>
<Copy SourceFiles="@(NUnitFiles)" DestinationFolder="..\..\bin\Tools\NUnit\Net-1.1"/>
<Copy SourceFiles="@(NUnitConfigFileNetv11)" DestinationFiles="@(NUnitConfigFileNetv11->'..\..\bin\Tools\NUnit\Net-1.1\nunit-console.exe.config')"/>
<Copy SourceFiles="@(NUnitConfigFile)" DestinationFolder="..\..\bin\Tools\NUnit"/>
<Copy SourceFiles="@(ToolFiles)" DestinationFolder="..\..\bin\Tools"/>
<!--

Loading…
Cancel
Save