Browse Source

Updated to NUnit 2.4.1

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2555 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 18 years ago
parent
commit
a1d5fdfec4
  1. 44
      src/AddIns/Misc/UnitTesting/Src/TestClass.cs
  2. 47
      src/AddIns/Misc/UnitTesting/Test/NamespaceFilterTests.cs
  3. 30
      src/AddIns/Misc/UnitTesting/Test/Project/TestMethodsInBaseClassTestFixture.cs
  4. 5
      src/AddIns/Misc/UnitTesting/Test/UnitTesting.Tests.csproj
  5. 9
      src/AddIns/Misc/UnitTesting/Test/Utils/MockTestCase.cs
  6. 20
      src/AddIns/Misc/UnitTesting/Test/Utils/MockTestFixture.cs
  7. 15
      src/Setup/Files.wxs
  8. 5
      src/Setup/Setup.wxs

44
src/AddIns/Misc/UnitTesting/Src/TestClass.cs

@ -358,37 +358,35 @@ namespace ICSharpCode.UnitTesting @@ -358,37 +358,35 @@ namespace ICSharpCode.UnitTesting
}
/// <summary>
/// First tries the last dotted part of the test result name as the
/// method name. If there is no matching method the preceding dotted
/// part is prefixed to the method name until a match is found.
/// This function adds the base class as a prefix and tries to find
/// the corresponding test method.
///
/// Given a test result of:
/// Actual method name:
///
/// RootNamespace.ClassName.BaseClass1.BaseClass2.TestMethod
/// RootNamespace.TestFixture.TestFixtureBaseClass.TestMethod
/// </summary>
/// <remarks>
/// NUnit 2.4 uses the correct test method name when a test
/// class uses a base class with test methods. It does
/// not prefix the test method name with the base class name
/// in the test results returned from nunit-console. It still
/// displays the name in the NUnit GUI with the base class
/// name prefixed. Older versions of NUnit-console (2.2.9) returned
/// the test result with the test method name as follows:
///
/// The method names tried are:
/// RootNamespace.TestFixture.BaseTestFixture.TestMethod
///
/// TestMethod
/// BaseClass2.TestMethod
/// BaseClass2.BaseClass1.TestMethod
/// etc.
/// </summary>
/// The test method name would have the base class name prefixed
/// to it.
/// </remarks>
TestMethod GetPrefixedTestMethod(string testResultName)
{
int index = 0;
IClass baseClass = c.BaseClass;
if (baseClass != null && TestClass.IsTestClass(baseClass)) {
string methodName = TestMethod.GetMethodName(testResultName);
string className = TestMethod.GetQualifiedClassName(testResultName);
do {
index = className.LastIndexOf('.');
if (index > 0) {
methodName = String.Concat(className.Substring(index + 1), ".", methodName);
TestMethod method = GetTestMethod(methodName);
if (method != null) {
return method;
}
className = className.Substring(0, index);
string actualMethodName = String.Concat(baseClass.Name, ".", methodName);
return GetTestMethod(actualMethodName);
}
} while (index > 0);
return null;
}
}

47
src/AddIns/Misc/UnitTesting/Test/NamespaceFilterTests.cs

@ -45,61 +45,58 @@ namespace UnitTesting.Tests @@ -45,61 +45,58 @@ namespace UnitTesting.Tests
}
[Test]
public void TestCaseNameMatchesNamespace()
public void NullTestCaseFullName()
{
NamespaceFilter filter = new NamespaceFilter("Project.Test");
MockTestCase testCase = new MockTestCase("Project.Test");
NamespaceFilter filter = new NamespaceFilter("Project.Tests");
MockTestCase testCase = new MockTestCase("Project.Tests.MyTest");
testCase.TestName.FullName = null;
Assert.IsFalse(filter.Pass(testCase));
}
[Test]
public void NullTestSuite()
public void TestCaseNameMatchesNamespace()
{
NamespaceSuite testSuite = null;
NamespaceFilter filter = new NamespaceFilter("Project.Tests");
Assert.IsFalse(filter.Pass(testSuite));
NamespaceFilter filter = new NamespaceFilter("Project.Test");
MockTestCase testCase = new MockTestCase("Project.Test");
Assert.IsFalse(filter.Pass(testCase));
}
[Test]
public void NamespaceTestSuiteIncluded()
public void NullTestFixture()
{
NamespaceSuite testSuite = new NamespaceSuite("Project", "Tests", 0);
TestFixture testFixture = null;
NamespaceFilter filter = new NamespaceFilter("Project.Tests");
Assert.IsTrue(filter.Pass(testSuite));
Assert.IsFalse(filter.Pass(testFixture));
}
[Test]
public void RootNamespaceTestSuiteIncluded()
public void TestFixtureIncluded()
{
NamespaceSuite testSuite = new NamespaceSuite("Project", 0);
MockTestFixture testFixture = new MockTestFixture("Project.Tests.MyTestFixture");
NamespaceFilter filter = new NamespaceFilter("Project.Tests");
Assert.IsTrue(filter.Pass(testSuite));
}
[Test]
public void ChildNamespaceTestSuiteIncluded()
{
NamespaceSuite testSuite = new NamespaceSuite("Project", "Tests", 0);
NamespaceFilter filter = new NamespaceFilter("Project");
Assert.IsTrue(filter.Pass(testSuite));
Assert.IsTrue(filter.Pass(testFixture));
}
[Test]
public void NamespaceTestSuiteExcluded()
public void TestFixtureExcluded()
{
NamespaceSuite testSuite = new NamespaceSuite("Project", "Different", 0);
MockTestFixture testFixture = new MockTestFixture("Project.Different");
NamespaceFilter filter = new NamespaceFilter("Project.Tests");
Assert.IsFalse(filter.Pass(testSuite));
Assert.IsFalse(filter.Pass(testFixture));
}
[Test]
public void RootNamespaceTestSuiteExcluded()
{
NamespaceSuite testSuite = new NamespaceSuite("Root", 0);
MockTestFixture testSuite = new MockTestFixture("Root");
NamespaceFilter filter = new NamespaceFilter("Project.Tests");
Assert.IsFalse(filter.Pass(testSuite));
}
/// <summary>
/// All test suite classes should pass. NUnit passes namespaces and
/// the assembly itself to the filter as a TestSuite object.
/// </summary>
[Test]
public void TestSuitePasses()
{

30
src/AddIns/Misc/UnitTesting/Test/Project/TestMethodsInBaseClassTestFixture.cs

@ -17,14 +17,22 @@ namespace UnitTesting.Tests.Project @@ -17,14 +17,22 @@ namespace UnitTesting.Tests.Project
/// <summary>
/// If a test fixture's base class has test attributes then
/// NUnit includes the base class test methods by prefixing
/// the base class name to them.
/// the base class name to them. In NUnit 2.2 this was true for
/// both the GUI and the test result information. In
/// NUnit 2.4 the GUI prefixes the base class to the method
/// name but the test result does not prefix the base class
/// to the name of the method.
///
/// [TestFixture]
/// public DerivedClass : BaseClass
///
/// Fully qualified test method is named:
/// Test method is shown in UI as:
///
/// RootNamespace.DerivedClass.BaseClass.BaseClassMethod.
/// BaseClass.BaseClassMethod
///
/// Test method name returned by NUnit-Console:
///
/// RootNamespace.DerivedClass.BaseClassMethod
/// </summary>
[TestFixture]
public class TestMethodsInBaseClassTestFixture
@ -34,7 +42,6 @@ namespace UnitTesting.Tests.Project @@ -34,7 +42,6 @@ namespace UnitTesting.Tests.Project
[SetUp]
public void SetUp()
{
MockProjectContent projectContent = new MockProjectContent();
projectContent.Language = LanguageProperties.None;
@ -83,7 +90,7 @@ namespace UnitTesting.Tests.Project @@ -83,7 +90,7 @@ namespace UnitTesting.Tests.Project
}
[Test]
public void GetTestClass()
public void UpdateTestResultUsingPrefixBaseClassName()
{
TestClassCollection testClasses = new TestClassCollection();
testClasses.Add(testClass);
@ -94,5 +101,18 @@ namespace UnitTesting.Tests.Project @@ -94,5 +101,18 @@ namespace UnitTesting.Tests.Project
Assert.AreEqual(TestResultType.Failure, testClass.Result);
}
[Test]
public void UpdateTestResult()
{
TestClassCollection testClasses = new TestClassCollection();
testClasses.Add(testClass);
TestResult testResult = new TestResult("RootNamespace.MyTestFixture.BaseMethod");
testResult.IsFailure = true;
testClasses.UpdateTestResult(testResult);
Assert.AreEqual(TestResultType.Failure, testClass.Result);
}
}
}

5
src/AddIns/Misc/UnitTesting/Test/UnitTesting.Tests.csproj

@ -45,6 +45,10 @@ @@ -45,6 +45,10 @@
<HintPath>..\..\..\..\Tools\NUnit\nunit.core.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="nunit.core.interfaces">
<HintPath>..\..\..\..\Tools\NUnit\nunit.core.interfaces.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\..\..\Tools\NUnit\nunit.framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
@ -65,6 +69,7 @@ @@ -65,6 +69,7 @@
<Compile Include="Utils\DerivedTestTreeView.cs" />
<Compile Include="Utils\DerivedUnitTestsPad.cs" />
<Compile Include="Utils\MockTestCase.cs" />
<Compile Include="Utils\MockTestFixture.cs" />
<Compile Include="Utils\MockTestTreeView.cs" />
<Compile Include="Utils\MockMember.cs" />
<Compile Include="Utils\MockClass.cs" />

9
src/AddIns/Misc/UnitTesting/Test/Utils/MockTestCase.cs

@ -12,12 +12,19 @@ namespace UnitTesting.Tests.Utils @@ -12,12 +12,19 @@ namespace UnitTesting.Tests.Utils
{
public class MockTestCase : TestCase
{
public MockTestCase(string name) : base(null, name)
public MockTestCase(string name) : base(CreateTestName(name))
{
}
public override void Run(TestCaseResult result)
{
}
static TestName CreateTestName(string name)
{
TestName testName = new TestName();
testName.FullName = name;
return testName;
}
}
}

20
src/AddIns/Misc/UnitTesting/Test/Utils/MockTestFixture.cs

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using NUnit.Core;
namespace UnitTesting.Tests.Utils
{
public class MockTestFixture : TestFixture
{
public MockTestFixture(string fullName) : base(typeof(MockTestFixture))
{
base.TestName.FullName = fullName;
}
}
}

15
src/Setup/Files.wxs

@ -446,6 +446,9 @@ @@ -446,6 +446,9 @@
<Component Guid="AB89A052-2D0A-426E-B755-6FA1A9C1C64F" Id="NUnitFrameworkDll" DiskId="1">
<File Source="..\..\bin\Tools\NUnit\nunit.framework.dll" Name="nuframe.dll" Id="nunit.framework.dll" LongName="nunit.framework.dll" />
</Component>
<Component Guid="D67E8EC9-2D98-4889-856F-78FD2BE35947" Id="NUnitCoreInterfacesDll" DiskId="1">
<File Id="nunit.core.interfaces.dll" KeyPath="yes" LongName="nunit.core.interfaces.dll" Name="nucorif.dll" Assembly=".net" AssemblyApplication="nunit.core.interfaces.dll" AssemblyManifest="nunit.core.interfaces.dll" Source="..\..\bin\Tools\NUnit\nunit.core.interfaces.dll" />
</Component>
<Directory Id="NUnitGacFolder" Name="GAC">
<!--
This is a dummy folder since if we just add the
@ -488,9 +491,21 @@ @@ -488,9 +491,21 @@
<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="EA6D0786-6103-42DE-8E49-A65FC622D181" Id="NUnitUiKitDllNetv11" DiskId="1">
<File Source="..\..\bin\Tools\NUnit\Net-1.1\nunit.uikit.dll" Name="nuuikit.dll" Id="Net_1.1.nunit.uikit.dll" LongName="nunit.uikit.dll" Assembly=".net" AssemblyApplication="Net_1.1.nunit.uikit.dll" AssemblyManifest="Net_1.1.nunit.uikit.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>
<Component Guid="6B1EB863-88A1-4B3F-95C5-FCAC7C525998" Id="NUnitCoreInterfacesDllNetv11" DiskId="1">
<File Source="..\..\bin\Tools\NUnit\Net-1.1\nunit.core.interfaces.dll" Name="nucori2.dll" Id="Net_1.1.nunit.core.interfaces.dll" LongName="nunit.core.interfaces.dll" KeyPath="yes" Assembly=".net" AssemblyApplication="Net_1.1.nunit.core.interfaces.dll" AssemblyManifest="Net_1.1.nunit.core.interfaces.dll" />
</Component>
<Component Guid="F81843D5-CECB-431C-A940-33E8CC478D01" Id="NUnitCoreExtensionsDllNetv11" DiskId="1">
<File Source="..\..\bin\Tools\NUnit\Net-1.1\nunit.core.extensions.dll" Name="NCOREX1.DLL" Id="Net_1.1.nunit.core.extensions.dll" LongName="nunit.core.extensions.dll" Assembly=".net" KeyPath="yes" AssemblyApplication="Net_1.1.nunit.core.extensions.dll" AssemblyManifest="Net_1.1.nunit.core.extensions.dll" />
</Component>
<Component Guid="A1F0ABAB-3E44-4BD3-B2E1-13B9E4F28DA5" Id="NUnitFrameworkDllNetv11" DiskId="1">
<File Source="..\..\bin\Tools\NUnit\Net-1.1\nunit.framework.dll" Name="nuframe.dll" Id="Net_1.1.nunit.framework.dll" LongName="nunit.framework.dll" />
</Component>
</Directory>
</Directory>
</Directory>

5
src/Setup/Setup.wxs

@ -241,10 +241,15 @@ @@ -241,10 +241,15 @@
<ComponentRef Id="NUnitCoreGacDll"/>
<ComponentRef Id="NUnitFrameworkGacDll"/>
<ComponentRef Id="NunitConsoleRunnerDll"/>
<ComponentRef Id="NUnitCoreInterfacesDll"/>
<ComponentRef Id="NUnitUiKitDllNetv11"/>
<ComponentRef Id="NUnitUtilDllNetv11"/>
<ComponentRef Id="NUnitConsoleNetv11Files"/>
<ComponentRef Id="NUnitCoreDllNetv11"/>
<ComponentRef Id="NUnitCoreExtensionsDllNetv11"/>
<ComponentRef Id="NUnitConsoleRunnerDllNetv11"/>
<ComponentRef Id="NUnitCoreInterfacesDllNetv11"/>
<ComponentRef Id="NUnitFrameworkDllNetv11"/>
<ComponentRef Id="ConversionStyleSheetFiles"/>
<ComponentRef Id="TextLibOptionsFiles"/>
<ComponentRef Id="OptionsFiles"/>

Loading…
Cancel
Save