From e0ae3327b6df981a6601efd6d669c13af345770d Mon Sep 17 00:00:00 2001 From: Ahmed Aderopo Alejo Date: Thu, 26 Sep 2019 15:22:22 -0300 Subject: [PATCH 1/5] Added Display Name to TestMethod Friendly "Display Name" for test method names "Method_names_should_be_readable_when_hinted" => "Method names should be readable when hinted" --- .../MSTest.CoreAdapter/ObjectModel/TestMethod.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs b/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs index 708e9b621f..6af3f24002 100644 --- a/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs +++ b/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs @@ -39,15 +39,21 @@ public TestMethod(string name, string fullClassName, string assemblyName, bool Debug.Assert(!string.IsNullOrEmpty(fullClassName), "Full className cannot be empty"); this.Name = name; + this.DisplayName = GetFriendlyName(name); this.FullClassName = fullClassName; this.AssemblyName = assemblyName; this.IsAsync = isAsync; } - + /// /// Gets the name of the test method /// public string Name { get; private set; } + + /// + /// Gets the display name of the test method + /// + public string DisplayName { get; private set; } /// /// Gets the full classname of the test method @@ -102,5 +108,7 @@ public string DeclaringClassFullName /// Gets a value indicating whether specifies test method is async /// public bool IsAsync { get; private set; } + + string GetFriendlyName(string name) => name?.Replace('_', ' '); } } From 2085b4457e93ce451be885aa5efece79dca8b83a Mon Sep 17 00:00:00 2001 From: Ahmed Aderopo Alejo Date: Thu, 26 Sep 2019 15:34:39 -0300 Subject: [PATCH 2/5] Added trim after friendly name generation --- src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs b/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs index 6af3f24002..8fd864efa5 100644 --- a/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs +++ b/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs @@ -109,6 +109,6 @@ public string DeclaringClassFullName /// public bool IsAsync { get; private set; } - string GetFriendlyName(string name) => name?.Replace('_', ' '); + string GetFriendlyName(string name) => name?.Replace('_', ' ')?.Trim(); } } From e9ad89a0467ac9a454e0dabda71a5e1be42675ec Mon Sep 17 00:00:00 2001 From: Ahmed Aderopo Alejo Date: Thu, 26 Sep 2019 15:40:11 -0300 Subject: [PATCH 3/5] Update ToTestCase to Use TestMethod.DisplayName --- src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestElement.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestElement.cs b/src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestElement.cs index 744e224101..bc0ecdfb00 100644 --- a/src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestElement.cs +++ b/src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestElement.cs @@ -110,7 +110,7 @@ internal TestCase ToTestCase() this.TestMethod.Name); TestCase testCase = new TestCase(fullName, TestAdapter.Constants.ExecutorUri, this.TestMethod.AssemblyName); - testCase.DisplayName = this.TestMethod.Name; + testCase.DisplayName = this.TestMethod.DisplayName; testCase.SetPropertyValue(TestAdapter.Constants.TestClassNameProperty, this.TestMethod.FullClassName); From 9501bf2c85a726b9fb32e23d16231adc2e40fee0 Mon Sep 17 00:00:00 2001 From: Ahmed Aderopo Alejo Date: Thu, 26 Sep 2019 16:09:42 -0300 Subject: [PATCH 4/5] Fixed the code convention issues TestMethod.cs(47,1): error SA1028: Code must not contain trailing whitespace TestMethod.cs(52,1): error SA1028: Code must not contain trailing whitespace TestMethod.cs(111,1): error SA1028: Code must not contain trailing whitespace TestMethod.cs(42,32): error SA1101: Prefix local calls with this TestMethod.cs(112,16): error SA1400: Element 'GetFriendlyName' must declare an access modifier --- src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs b/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs index 8fd864efa5..ba3cc8952b 100644 --- a/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs +++ b/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs @@ -44,12 +44,12 @@ public TestMethod(string name, string fullClassName, string assemblyName, bool this.AssemblyName = assemblyName; this.IsAsync = isAsync; } - + /// /// Gets the name of the test method /// public string Name { get; private set; } - + /// /// Gets the display name of the test method /// @@ -108,7 +108,7 @@ public string DeclaringClassFullName /// Gets a value indicating whether specifies test method is async /// public bool IsAsync { get; private set; } - - string GetFriendlyName(string name) => name?.Replace('_', ' ')?.Trim(); + + private string GetFriendlyName(string name) => name?.Replace('_', ' ')?.Trim(); } } From e6b7236ed996bbb152aede2a7b6e848828ef85ac Mon Sep 17 00:00:00 2001 From: Ahmed Aderopo Alejo Date: Thu, 26 Sep 2019 16:48:26 -0300 Subject: [PATCH 5/5] Code Convention Fix TestMethod.cs(42,32): error SA1101: Prefix local calls with this --- src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs b/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs index ba3cc8952b..64736c30c0 100644 --- a/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs +++ b/src/Adapter/MSTest.CoreAdapter/ObjectModel/TestMethod.cs @@ -39,7 +39,7 @@ public TestMethod(string name, string fullClassName, string assemblyName, bool Debug.Assert(!string.IsNullOrEmpty(fullClassName), "Full className cannot be empty"); this.Name = name; - this.DisplayName = GetFriendlyName(name); + this.DisplayName = this.GetFriendlyName(name); this.FullClassName = fullClassName; this.AssemblyName = assemblyName; this.IsAsync = isAsync;