Skip to content

Commit 06cf5cf

Browse files
authored
Fix for the trx classname being wrongly stamped when testname and fullqualifiedname are same. (#2014)
1 parent 77ab51b commit 06cf5cf

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

  • src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility
  • test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Utility

src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ private static string GetTestClassName(string testName, string fullyQualifiedNam
606606

607607
// In case, fullyQualifiedName ends with testName, className is checked within remaining value of fullyQualifiedName.
608608
// Example: In case, testName = TestMethod1(2, 3, 4.0d) and fullyQualifiedName = TestProject1.Class1.TestMethod1(2, 3, 4.0d), className will be checked within 'TestProject1.Class1.' only
609-
var nameToCheck = fullyQualifiedName.EndsWith(testName) ?
609+
var nameToCheck = !fullyQualifiedName.Equals(testName, StringComparison.OrdinalIgnoreCase) && fullyQualifiedName.EndsWith(testName) ?
610610
fullyQualifiedName.Substring(0, fullyQualifiedName.Length - testName.Length) :
611611
fullyQualifiedName;
612612

test/Microsoft.TestPlatform.Extensions.TrxLogger.UnitTests/Utility/ConverterTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ public void ToTestElementShouldNotFailWhenThereIsNoTestCategoreis()
9999
CollectionAssert.AreEqual(expected, unitTestElement.TestCategories.ToArray());
100100
}
101101

102+
[TestMethod]
103+
public void ToTestElementShouldContainExpectedTestMethodPropertiesIfFqnIsSameAsTestName()
104+
{
105+
var expectedClassName = "TestProject1.Class1";
106+
var fullyQualifiedName = expectedClassName + "." + "TestMethod1";
107+
var testName = "TestProject1.Class1.TestMethod1";
108+
109+
ValidateTestMethodProperties(testName, fullyQualifiedName, expectedClassName);
110+
}
111+
102112
[TestMethod]
103113
public void ToTestElementShouldContainExpectedTestMethodPropertiesIfFqnEndsWithTestName()
104114
{

0 commit comments

Comments
 (0)