diff options
author | Mike Krüger <mkrueger@novell.com> | 2011-04-28 11:10:04 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@novell.com> | 2011-04-28 11:10:04 +0400 |
commit | b686559c27df4ad7703a6495f227c58c13036fd6 (patch) | |
tree | 5e62cb71252dd130000fd1ded3c3d3cdb0849eb7 /main/src/addins/NUnit | |
parent | d9b7cbb4dcf8ae35b93e1717c2cd13583aaa5bda (diff) |
Fixed 'Bug 677228 - RemotingException isn't counted as failure'.
Diffstat (limited to 'main/src/addins/NUnit')
4 files changed, 32 insertions, 15 deletions
diff --git a/main/src/addins/NUnit/Services/ExternalTestRunner.cs b/main/src/addins/NUnit/Services/ExternalTestRunner.cs index f0df518505..a737b2de4d 100644 --- a/main/src/addins/NUnit/Services/ExternalTestRunner.cs +++ b/main/src/addins/NUnit/Services/ExternalTestRunner.cs @@ -118,17 +118,19 @@ namespace MonoDevelop.NUnit.External public void SuiteFinished (TestSuiteResult result) { - wrapped.SuiteFinished (GetTestName (result.Test.TestName), GetLocalTestResult (result)); + testSuites.Pop (); + wrapped.SuiteFinished (GetTestName (result.Test), GetLocalTestResult (result)); } - + Stack<string> testSuites = new Stack<string>(); public void SuiteStarted (TestName suite) { + testSuites.Push (suite.FullName); wrapped.SuiteStarted (GetTestName (suite)); } public void TestFinished (TestCaseResult result) { - wrapped.TestFinished (GetTestName (result.Test.TestName), GetLocalTestResult (result)); + wrapped.TestFinished (GetTestName (result.Test), GetLocalTestResult (result)); } public void TestOutput (TestOutput testOutput) @@ -155,6 +157,19 @@ namespace MonoDevelop.NUnit.External return null; } + string GetTestName (ITest t) + { + if (t == null) + return null; + // Theoretically t.TestName.FullName should work, but when a test class inherits from a base + // class that contains tests the full name is that one of the base class, which is wrong. + // I suspect that is a NUnit bug, when this is fixed this code should be overworked and the testSuites stack be removed. + // see: Bug 677228 - RemotingException isn't counted as failure + if (t.TestType != "Test Case" || testSuites.Count == 0) + return t.TestName.FullName; + return testSuites.Peek () + "." + t.TestName.Name; + } + public string GetTestName (TestName t) { if (t == null) diff --git a/main/src/addins/NUnit/Services/NUnitAssemblyTestSuite.cs b/main/src/addins/NUnit/Services/NUnitAssemblyTestSuite.cs index 9e83c1a485..a27228032d 100644 --- a/main/src/addins/NUnit/Services/NUnitAssemblyTestSuite.cs +++ b/main/src/addins/NUnit/Services/NUnitAssemblyTestSuite.cs @@ -239,12 +239,13 @@ namespace MonoDevelop.NUnit void FillTests (NunitTestInfo ti) { - if (ti.Tests == null) return; + if (ti.Tests == null) + return; foreach (NunitTestInfo test in ti.Tests) { if (test.Tests != null) Tests.Add (new NUnitTestSuite (this, test)); else - Tests.Add (new NUnitTestCase (this, test)); + Tests.Add (new NUnitTestCase (this, test, test.PathName)); } oldList = new UnitTest [Tests.Count]; Tests.CopyTo (oldList, 0); @@ -324,7 +325,7 @@ namespace MonoDevelop.NUnit protected override UnitTestResult OnRun (TestContext testContext) { - return RunUnitTest (this, "", null, testContext); + return RunUnitTest (this, "", "", null, testContext); } protected override bool OnCanRun (MonoDevelop.Core.Execution.IExecutionHandler executionContext) @@ -332,15 +333,14 @@ namespace MonoDevelop.NUnit return Runtime.ProcessService.IsValidForRemoteHosting (executionContext); } - internal UnitTestResult RunUnitTest (UnitTest test, string suiteName, string testName, TestContext testContext) + internal UnitTestResult RunUnitTest (UnitTest test, string suiteName, string pathName, string testName, TestContext testContext) { ExternalTestRunner runner = (ExternalTestRunner) Runtime.ProcessService.CreateExternalProcessObject (typeof(ExternalTestRunner), testContext.ExecutionContext); LocalTestMonitor localMonitor = new LocalTestMonitor (testContext, runner, test, suiteName, testName != null); ITestFilter filter = null; - if (testName != null) { - filter = new TestNameFilter (suiteName + "." + testName); + filter = new TestNameFilter (pathName + "." + testName); } else { NUnitCategoryOptions categoryOptions = (NUnitCategoryOptions) test.GetOptions (typeof(NUnitCategoryOptions)); if (categoryOptions.EnableFilter && categoryOptions.Categories.Count > 0) { diff --git a/main/src/addins/NUnit/Services/NUnitTestCase.cs b/main/src/addins/NUnit/Services/NUnitTestCase.cs index a8f1cfae57..1e6192157b 100644 --- a/main/src/addins/NUnit/Services/NUnitTestCase.cs +++ b/main/src/addins/NUnit/Services/NUnitTestCase.cs @@ -40,10 +40,12 @@ namespace MonoDevelop.NUnit { NUnitAssemblyTestSuite rootSuite; string className; + string pathName; - public NUnitTestCase (NUnitAssemblyTestSuite rootSuite, NunitTestInfo tinfo): base (tinfo.Name) + public NUnitTestCase (NUnitAssemblyTestSuite rootSuite, NunitTestInfo tinfo, string className) : base (tinfo.Name) { - className = tinfo.PathName; + this.className = className; + this.pathName = tinfo.PathName; this.rootSuite = rootSuite; } @@ -53,7 +55,7 @@ namespace MonoDevelop.NUnit protected override UnitTestResult OnRun (TestContext testContext) { - return rootSuite.RunUnitTest (this, className, Name, testContext); + return rootSuite.RunUnitTest (this, className, pathName, Name, testContext); } protected override bool OnCanRun (MonoDevelop.Core.Execution.IExecutionHandler executionContext) diff --git a/main/src/addins/NUnit/Services/NUnitTestSuite.cs b/main/src/addins/NUnit/Services/NUnitTestSuite.cs index f5d2ab267b..0449ed632d 100644 --- a/main/src/addins/NUnit/Services/NUnitTestSuite.cs +++ b/main/src/addins/NUnit/Services/NUnitTestSuite.cs @@ -44,7 +44,7 @@ namespace MonoDevelop.NUnit public NUnitTestSuite (NUnitAssemblyTestSuite rootSuite, NunitTestInfo tinfo): base (tinfo.Name) { - fullName = tinfo.PathName != null && tinfo.PathName.Length > 0 ? tinfo.PathName + "." + tinfo.Name : tinfo.Name; + fullName = !string.IsNullOrEmpty (tinfo.PathName) ? tinfo.PathName + "." + tinfo.Name : tinfo.Name; this.testInfo = tinfo; this.rootSuite = rootSuite; } @@ -61,7 +61,7 @@ namespace MonoDevelop.NUnit protected override UnitTestResult OnRun (TestContext testContext) { - return rootSuite.RunUnitTest (this, fullName, null, testContext); + return rootSuite.RunUnitTest (this, fullName, fullName, null, testContext); } protected override bool OnCanRun (MonoDevelop.Core.Execution.IExecutionHandler executionContext) @@ -79,7 +79,7 @@ namespace MonoDevelop.NUnit if (test.Tests != null) Tests.Add (new NUnitTestSuite (rootSuite, test)); else - Tests.Add (new NUnitTestCase (rootSuite, test)); + Tests.Add (new NUnitTestCase (rootSuite, test, ClassName)); } } |