diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs index ee18437d2b..f91f8c5b74 100644 --- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs +++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs @@ -684,7 +684,8 @@ private TestElement CreateTestElement(Guid testId, string name, string fullyQual { var codeBase = source; var className = GetTestClassName(name, fullyQualifiedName, source); - var testMethod = new TestMethod(name, className); + var testMethodName = fullyQualifiedName.StartsWith(className) ? fullyQualifiedName.Remove(0, $"{className}.".Length) : fullyQualifiedName; + var testMethod = new TestMethod(testMethodName, className); testElement = new UnitTestElement(testId, name, adapter, testMethod); (testElement as UnitTestElement).CodeBase = codeBase; diff --git a/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Utility/ConverterTests.cs b/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Utility/ConverterTests.cs index a86ef7987d..6b8cc39ed8 100644 --- a/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Utility/ConverterTests.cs +++ b/test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Utility/ConverterTests.cs @@ -167,9 +167,10 @@ private void ValidateTestMethodProperties(string testName, string fullyQualified TestPlatformObjectModel.TestResult result = new TestPlatformObjectModel.TestResult(testCase); var unitTestElement = this.converter.ToTestElement(testCase.Id, Guid.Empty, Guid.Empty, testName, TrxLoggerConstants.UnitTestType, testCase) as UnitTestElement; + var expectedTestName = fullyQualifiedName.StartsWith(expectedClassName) ? fullyQualifiedName.Remove(0, $"{expectedClassName}.".Length) : fullyQualifiedName; Assert.AreEqual(expectedClassName, unitTestElement.TestMethod.ClassName); - Assert.AreEqual(testName, unitTestElement.TestMethod.Name); + Assert.AreEqual(expectedTestName, unitTestElement.TestMethod.Name); } private static TestCase CreateTestCase(string fullyQualifiedName)