Browse Source

Updated to NUnit 2.4.6. The Unit Testing addin now uses the nunit-console's new /run command line parameter introduced in NUnit 2.4.6. This can be used to execute a test method, class or namespace.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2790 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 18 years ago
parent
commit
6c7f8e0378
  1. 26
      src/AddIns/Misc/UnitTesting/Src/UnitTestApplicationStartHelper.cs
  2. 114
      src/AddIns/Misc/UnitTesting/Test/NamespaceFilterTests.cs
  3. 20
      src/AddIns/Misc/UnitTesting/Test/UnitTestCommandLineTests.cs
  4. 1
      src/AddIns/Misc/UnitTesting/Test/UnitTesting.Tests.csproj
  5. 6
      src/AddIns/Misc/UnitTesting/UnitTesting.sln

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

@ -156,22 +156,22 @@ namespace ICSharpCode.UnitTesting @@ -156,22 +156,22 @@ namespace ICSharpCode.UnitTesting
b.Append(Results);
b.Append('"');
}
string run = null;
if (NamespaceFilter != null) {
b.Append(" /namespaceFilter=\"");
b.Append(NamespaceFilter);
b.Append('"');
}
if (Fixture != null) {
b.Append(" /fixture=\"");
b.Append(Fixture);
b.Append('"');
run = NamespaceFilter;
} else if (Fixture != null) {
if (Test != null) {
b.Append(" /testMethodName=\"");
b.Append(Fixture);
b.Append('.');
b.Append(Test);
b.Append('"');
run = Fixture + "." + Test;
} else {
run = Fixture;
}
} else if (Test != null) {
run = Test;
}
if (run != null) {
b.Append(" /run=\"");
b.Append(run);
b.Append('"');
}
return b.ToString();
}

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

@ -1,114 +0,0 @@ @@ -1,114 +0,0 @@
// <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.ConsoleRunner;
using NUnit.Core;
using NUnit.Framework;
using UnitTesting.Tests.Utils;
namespace UnitTesting.Tests
{
/// <summary>
/// Tests the NamespaceFilter class that is a part of SharpDevelop's
/// customised nunit-console.exe.
/// </summary>
[TestFixture]
public class NamespaceFilterTests
{
[Test]
public void TestCaseExcluded()
{
NamespaceFilter filter = new NamespaceFilter("Project.Tests");
MockTestCase testCase = new MockTestCase("Project.NotTests.MyTest");
Assert.IsFalse(filter.Pass(testCase));
}
[Test]
public void TestCaseIncluded()
{
NamespaceFilter filter = new NamespaceFilter("Project.Tests");
MockTestCase testCase = new MockTestCase("Project.Tests.MyTest");
Assert.IsTrue(filter.Pass(testCase));
}
[Test]
public void NullTestCase()
{
NamespaceFilter filter = new NamespaceFilter("Project.Tests");
MockTestCase testCase = null;
Assert.IsFalse(filter.Pass(testCase));
}
[Test]
public void NullTestCaseFullName()
{
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 TestCaseNameMatchesNamespace()
{
NamespaceFilter filter = new NamespaceFilter("Project.Test");
MockTestCase testCase = new MockTestCase("Project.Test");
Assert.IsFalse(filter.Pass(testCase));
}
[Test]
public void NullTestFixture()
{
TestFixture testFixture = null;
NamespaceFilter filter = new NamespaceFilter("Project.Tests");
Assert.IsFalse(filter.Pass(testFixture));
}
[Test]
public void TestFixtureIncluded()
{
MockTestFixture testFixture = new MockTestFixture("Project.Tests.MyTestFixture");
NamespaceFilter filter = new NamespaceFilter("Project.Tests");
Assert.IsTrue(filter.Pass(testFixture));
}
[Test]
public void TestFixtureExcluded()
{
MockTestFixture testFixture = new MockTestFixture("Project.Different");
NamespaceFilter filter = new NamespaceFilter("Project.Tests");
Assert.IsFalse(filter.Pass(testFixture));
}
[Test]
public void RootNamespaceTestSuiteExcluded()
{
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()
{
TestSuite testSuite = new TestSuite("TestSuite");
NamespaceFilter filter = new NamespaceFilter("Tests");
Assert.IsTrue(filter.Pass(testSuite));
}
[Test]
public void NamespaceFilterClassIsSerializable()
{
Assert.IsTrue(typeof(NamespaceFilter).IsSerializable);
}
}
}

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

@ -84,7 +84,19 @@ namespace UnitTesting.Tests @@ -84,7 +84,19 @@ namespace UnitTesting.Tests
helper.ShadowCopy = true;
helper.Fixture = "TestFixture";
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /fixture=\"TestFixture\"";
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture\"";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
[Test]
public void TestNamespace()
{
helper.Initialize(project, null, null);
helper.NoLogo = false;
helper.ShadowCopy = true;
helper.NamespaceFilter = "TestFixture";
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture\"";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
@ -109,7 +121,7 @@ namespace UnitTesting.Tests @@ -109,7 +121,7 @@ namespace UnitTesting.Tests
helper.Fixture = "TestFixture";
helper.Test = "Test";
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /fixture=\"TestFixture\" /testMethodName=\"TestFixture.Test\"";
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture.Test\"";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
@ -122,7 +134,7 @@ namespace UnitTesting.Tests @@ -122,7 +134,7 @@ namespace UnitTesting.Tests
helper.NoLogo = false;
helper.ShadowCopy = true;
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /fixture=\"TestFixture\" /testMethodName=\"TestFixture.Test\"";
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture.Test\"";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}
@ -133,7 +145,7 @@ namespace UnitTesting.Tests @@ -133,7 +145,7 @@ namespace UnitTesting.Tests
helper.NoLogo = false;
helper.ShadowCopy = true;
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /namespaceFilter=\"Project.MyTests\"";
string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"Project.MyTests\"";
Assert.AreEqual(expectedCommandLine, helper.GetArguments());
}

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

@ -59,7 +59,6 @@ @@ -59,7 +59,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="NamespaceFilterTests.cs" />
<Compile Include="Project\BaseTestMethodTestFixture.cs" />
<Compile Include="TestableConditionTests.cs" />
<Compile Include="Tree\MultipleTestProjectsTestFixture.cs" />

6
src/AddIns/Misc/UnitTesting/UnitTesting.sln

@ -1,5 +1,7 @@ @@ -1,5 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.1.0.1856

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
# SharpDevelop 3.0.0.2745
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting.Tests", "Test\UnitTesting.Tests.csproj", "{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}"

Loading…
Cancel
Save