diff options
author | Keting Yang <ketyang@microsoft.com> | 2019-12-09 17:42:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-09 17:42:16 +0300 |
commit | 97d54a4e8fd4bbeb066be8d7b3ae905894e35a7f (patch) | |
tree | 4049a457922272de566fa1360ae111d5c195fedf /main/src | |
parent | 1d04bd0703fed8c5cdb87b0e8b41aa5200f32401 (diff) | |
parent | 59698ce4056b0c8d2db5b84d2b60409b31dfe51a (diff) |
Merge pull request #9374 from mono/vsts-901156-unit-test-nestingnet5
[Unit Test] Fix the nesting for unit tests
Diffstat (limited to 'main/src')
2 files changed, 10 insertions, 11 deletions
diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/DiscoveredTests.cs b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/DiscoveredTests.cs index ba8f77b1ca..e6cd75e0ca 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/DiscoveredTests.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/DiscoveredTests.cs @@ -48,7 +48,7 @@ namespace MonoDevelop.UnitTesting.VsTest { tests.Sort (OrderByName); - var parentNamespace = new VsTestNamespaceTestGroup (projectTestSuite, null, projectTestSuite.Project, String.Empty); + var parentNamespace = new VsTestNamespaceTestGroup (projectTestSuite, null, projectTestSuite.Project, string.Empty); parentNamespace.AddTests (tests); return parentNamespace.Tests; } diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestNamespaceTestGroup.cs b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestNamespaceTestGroup.cs index 60c1c951a0..5092b235b7 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestNamespaceTestGroup.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.VsTest/VsTestNamespaceTestGroup.cs @@ -64,19 +64,18 @@ namespace MonoDevelop.UnitTesting.VsTest internal void AddTest (VsTestUnitTest VsTestTest) { - string childNamespace = VsTestTest.GetChildNamespace (FixtureTypeNamespace); - if (string.IsNullOrEmpty (childNamespace)) { - if (currentClass == null || currentClass.FixtureTypeName != VsTestTest.FixtureTypeName) { - currentClass = new VsTestTestClass (testRunner, Project, VsTestTest); - Tests.Add (currentClass); - } - currentClass.Tests.Add (VsTestTest); - } else if (currentNamespace != this && currentNamespace.Name == childNamespace) { - currentNamespace.AddTest (VsTestTest); - } else { + string childNamespace = VsTestTest.FixtureTypeNamespace; + + if (currentNamespace == null || currentNamespace.Name != childNamespace) { currentNamespace = new VsTestNamespaceTestGroup (testRunner, currentNamespace, Project, childNamespace); currentNamespace.AddTest (VsTestTest); Tests.Add (currentNamespace); + } else { + if (currentNamespace.currentClass == null || currentNamespace.currentClass.FixtureTypeName != VsTestTest.FixtureTypeName) { + currentNamespace.currentClass = new VsTestTestClass (testRunner, Project, VsTestTest); + currentNamespace.Tests.Add (currentNamespace.currentClass); + } + currentNamespace.currentClass.Tests.Add (VsTestTest); } } |