diff options
author | Mike Krüger <mikkrg@microsoft.com> | 2018-12-10 09:57:59 +0300 |
---|---|---|
committer | Mike Krüger <mikkrg@microsoft.com> | 2018-12-10 15:48:52 +0300 |
commit | cd3c10bb8251b2059cffad6922b8dcac5a9d91fe (patch) | |
tree | 5203dc7ad44e5914288d6d8787287d66882f70f8 | |
parent | 737e87d6d03cd6a49841924306660169d33fecb9 (diff) |
[UnitTests] Fix test results pad.
Introduced a new ID which is clearer the source code connection ID.
7 files changed, 53 insertions, 15 deletions
diff --git a/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitTestCase.cs b/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitTestCase.cs index 968d750e07..e57e9eb677 100644 --- a/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitTestCase.cs +++ b/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitTestCase.cs @@ -43,7 +43,7 @@ namespace MonoDevelop.UnitTesting.NUnit this.className = className; this.pathName = tinfo.PathName; this.rootSuite = rootSuite; - this.TestId = tinfo.TestId; + this.TestSourceCodeDocumentId = this.TestId = tinfo.TestId; this.IsExplicit = tinfo.IsExplicit; } diff --git a/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitTestSuite.cs b/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitTestSuite.cs index 54268b3bf5..c75fbafa0f 100644 --- a/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitTestSuite.cs +++ b/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitTestSuite.cs @@ -42,7 +42,7 @@ namespace MonoDevelop.UnitTesting.NUnit fullName = !string.IsNullOrEmpty (tinfo.PathName) ? tinfo.PathName + "." + tinfo.Name : tinfo.Name; this.testInfo = tinfo; this.rootSuite = rootSuite; - this.TestId = tinfo.TestId; + this.TestSourceCodeDocumentId = this.TestId = tinfo.TestId; this.canMergeWithParent = !string.IsNullOrEmpty (tinfo.PathName) && string.IsNullOrEmpty (tinfo.FixtureTypeName) && string.IsNullOrEmpty (tinfo.FixtureTypeNamespace); diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestTestClass.cs b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestTestClass.cs index 5d36816915..1cd77f293a 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestTestClass.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestTestClass.cs @@ -43,7 +43,7 @@ namespace MonoDevelop.UnitTesting.VsTest this.Project = project; this.testRunner = testRunner; FixtureTypeName = vsTestUnit.FixtureTypeName; - TestId = string.IsNullOrEmpty (vsTestUnit.FixtureTypeNamespace) ? FixtureTypeName : vsTestUnit.FixtureTypeNamespace + "." + FixtureTypeName; + TestSourceCodeDocumentId = string.IsNullOrEmpty (vsTestUnit.FixtureTypeNamespace) ? FixtureTypeName : vsTestUnit.FixtureTypeNamespace + "." + FixtureTypeName; } protected override UnitTestResult OnRun (TestContext testContext) diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestUnitTest.cs b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestUnitTest.cs index 0d13dda33c..f7c15346f6 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestUnitTest.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestUnitTest.cs @@ -59,7 +59,8 @@ namespace MonoDevelop.UnitTesting.VsTest void Init () { - TestId = test.FullyQualifiedName; + TestId = test.Id.ToString (); + TestSourceCodeDocumentId = test.FullyQualifiedName; if (!string.IsNullOrEmpty (test.CodeFilePath)) sourceCodeLocation = new SourceCodeLocation (test.CodeFilePath, test.LineNumber, 0); else { diff --git a/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractUnitTestEditorExtension.cs b/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractUnitTestEditorExtension.cs index d1e5822717..58449a06a8 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractUnitTestEditorExtension.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractUnitTestEditorExtension.cs @@ -152,7 +152,7 @@ namespace MonoDevelop.UnitTesting public override Xwt.Drawing.Image GetStatusIcon (string unitTestIdentifier, string caseId = null) { - var test = UnitTestService.SearchTestById (unitTestIdentifier + caseId); + var test = UnitTestService.SearchTestByDocumentId (unitTestIdentifier + caseId); if (test != null) return test.StatusIcon; return TestStatusIcon.None; @@ -160,7 +160,7 @@ namespace MonoDevelop.UnitTesting public override bool IsFailure (string unitTestIdentifier, string caseId = null) { - var test = UnitTestService.SearchTestById (unitTestIdentifier + caseId); + var test = UnitTestService.SearchTestByDocumentId (unitTestIdentifier + caseId); if (test != null) { var result = test.GetLastResult (); if (result != null) @@ -171,7 +171,7 @@ namespace MonoDevelop.UnitTesting public override string GetMessage (string unitTestIdentifier, string caseId = null) { - var test = UnitTestService.SearchTestById (unitTestIdentifier + caseId); + var test = UnitTestService.SearchTestByDocumentId (unitTestIdentifier + caseId); if (test != null) { var result = test.GetLastResult (); if (result != null) @@ -182,7 +182,7 @@ namespace MonoDevelop.UnitTesting public override bool HasResult (string unitTestIdentifier, string caseId = null) { - return UnitTestService.SearchTestById (unitTestIdentifier + caseId) != null; + return UnitTestService.SearchTestByDocumentId (unitTestIdentifier + caseId) != null; } public override void PopupContextMenu (UnitTestLocation unitTest, int x, int y) @@ -240,7 +240,7 @@ namespace MonoDevelop.UnitTesting var label = "Test" + id; string tooltip = null; - var test = UnitTestService.SearchTestById (unitTest.UnitTestIdentifier + id); + var test = UnitTestService.SearchTestByDocumentId (unitTest.UnitTestIdentifier + id); if (test != null) { var result = test.GetLastResult (); if (result != null && result.IsFailure) { @@ -292,7 +292,7 @@ namespace MonoDevelop.UnitTesting bool TimeoutHandler () { - var test = UnitTestService.SearchTestById (testCase); + var test = UnitTestService.SearchTestByDocumentId (testCase); if (test != null) { RunTest (test); timeoutHandler = 0; @@ -308,7 +308,7 @@ namespace MonoDevelop.UnitTesting IdeApp.ProjectOperations.IsRunning (IdeApp.ProjectOperations.CurrentSelectedSolution)) return; - var foundTest = UnitTestService.SearchTestById (testCase); + var foundTest = UnitTestService.SearchTestByDocumentId (testCase); if (foundTest != null) { RunTest (foundTest); return; @@ -321,7 +321,7 @@ namespace MonoDevelop.UnitTesting await UnitTestService.RefreshTests (CancellationToken.None); } - foundTest = UnitTestService.SearchTestById (testCase); + foundTest = UnitTestService.SearchTestByDocumentId (testCase); if (foundTest != null) RunTest (foundTest); else @@ -330,7 +330,7 @@ namespace MonoDevelop.UnitTesting internal void Select (object sender, EventArgs e) { - var test = UnitTestService.SearchTestById (testCase); + var test = UnitTestService.SearchTestByDocumentId (testCase); if (test == null) return; UnitTestService.CurrentSelectedTest = test; diff --git a/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTest.cs b/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTest.cs index cf5f615d0c..da956f00ae 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTest.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTest.cs @@ -238,7 +238,16 @@ namespace MonoDevelop.UnitTesting get; protected set; } - + + /// <summary> + /// Used for the text editor integration to identify the source code member connected to the unit test. + /// </summary> + public string TestSourceCodeDocumentId { + get; + protected set; + } + + public string FullName { get { if (parent != null) diff --git a/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs b/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs index aaa2daa49d..9f89cee925 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs @@ -243,6 +243,16 @@ namespace MonoDevelop.UnitTesting return null; } + public static UnitTest SearchTestByDocumentId (string id) + { + foreach (UnitTest t in RootTests) { + UnitTest r = SearchTestByDocumentId (t, id); + if (r != null) + return r; + } + return null; + } + static UnitTest SearchTest (UnitTest test, string fullName) { @@ -270,7 +280,7 @@ namespace MonoDevelop.UnitTesting return test; UnitTestGroup group = test as UnitTestGroup; - if (group != null) { + if (group != null) { foreach (UnitTest t in group.Tests) { UnitTest result = SearchTestById (t, id); if (result != null) @@ -280,6 +290,24 @@ namespace MonoDevelop.UnitTesting return null; } + static UnitTest SearchTestByDocumentId (UnitTest test, string id) + { + if (test == null) + return null; + if (test.TestSourceCodeDocumentId == id) + return test; + + UnitTestGroup group = test as UnitTestGroup; + if (group != null) { + foreach (UnitTest t in group.Tests) { + UnitTest result = SearchTestByDocumentId (t, id); + if (result != null) + return result; + } + } + return null; + } + public static UnitTest FindRootTest (WorkspaceObject item) { return FindRootTest (RootTests, item); |