#! /bin/sh /usr/share/dpatch/dpatch-run ## 06_nunit_2.4.dpatch by Jelmer Vernooij ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Update NUnit task to work with NUnit 2.4.7 @DPATCH@ diff -ur nant-0.85/src/NAnt.NUnit/NUnit2/NUnit2Task.cs nant-0.85.dfsg1-newnunit/src/NAnt.NUnit/NUnit2/NUnit2Task.cs --- nant-0.85/src/NAnt.NUnit/NUnit2/NUnit2Task.cs 2006-04-23 19:53:12.000000000 +0200 +++ nant-0.85.dfsg1-newnunit/src/NAnt.NUnit/NUnit2/NUnit2Task.cs 2008-06-14 16:50:35.000000000 +0200 @@ -31,6 +31,7 @@ using System.Xml.XPath; using NUnit.Core; +using NUnit.Core.Filters; using TestCase = NUnit.Core.TestCase; using TestOutput = NUnit.Core.TestOutput; using NUnit.Framework; @@ -185,16 +186,16 @@ EventListener listener = new EventCollector(logWriter, logWriter); foreach (NUnit2Test testElement in Tests) { - IFilter categoryFilter = null; + ITestFilter categoryFilter = null; // include or exclude specific categories string categories = testElement.Categories.Includes.ToString(); if (!StringUtils.IsNullOrEmpty(categories)) { - categoryFilter = new CategoryFilter(categories.Split(','), false); + categoryFilter = new CategoryFilter(categories.Split(',')); } else { categories = testElement.Categories.Excludes.ToString(); if (!StringUtils.IsNullOrEmpty(categories)) { - categoryFilter = new CategoryFilter(categories.Split(','), true); + categoryFilter = new NotFilter(new CategoryFilter(categories.Split(','))); } } @@ -203,27 +204,22 @@ try { TestRunner runner = domain.CreateRunner(new FileInfo(testAssembly), testElement.AppConfigFile); + TestPackage package = new TestPackage(testAssembly); - Test test = null; - if (testElement.TestName != null) { - test = runner.Load(testAssembly, testElement.TestName); - } else { - test = runner.Load(testAssembly); - } - - if (test == null) { + bool test = runner.Load(package); + if (!test) { Log(Level.Warning, "Assembly \"{0}\" contains no tests.", testAssembly); continue; } - // set category filter - if (categoryFilter != null) { - runner.Filter = categoryFilter; - } - + TestResult result; // run test - TestResult result = runner.Run(listener); + if (categoryFilter != null) { + result = runner.Run(listener, categoryFilter); + } else { + result = runner.Run(listener); + } // flush test output to log logWriter.Flush(); @@ -371,7 +367,7 @@ #endregion Private Instance Methods - private class EventCollector : LongLivingMarshalByRefObject, EventListener { + private class EventCollector : MarshalByRefObject, EventListener { private TextWriter outWriter; private TextWriter errorWriter; private string currentTestName; @@ -382,10 +378,10 @@ this.currentTestName = string.Empty; } - public void RunStarted(Test[] tests) { + public void RunStarted(string name, int testcount) { } - public void RunFinished(TestResult[] results) { + public void RunFinished(TestResult result) { } public void RunFinished(Exception exception) { @@ -395,11 +391,11 @@ currentTestName = string.Empty; } - public void TestStarted(TestCase testCase) { - currentTestName = testCase.FullName; + public void TestStarted(TestName testName) { + currentTestName = testName.FullName; } - public void SuiteStarted(TestSuite suite) { + public void SuiteStarted(TestName testName) { } public void SuiteFinished(TestSuiteResult suiteResult) { @@ -423,4 +419,4 @@ } } } -} \ Kein Zeilenumbruch am Dateiende. +}