Skip to content

Commit

Permalink
Fix for the trx classname being wrongly stamped when testname and ful…
Browse files Browse the repository at this point in the history
…lqualifiedname are same. (#2014)
  • Loading branch information
singhsarab committed May 10, 2019
1 parent 77ab51b commit 06cf5cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ private static string GetTestClassName(string testName, string fullyQualifiedNam

// In case, fullyQualifiedName ends with testName, className is checked within remaining value of fullyQualifiedName.
// 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
var nameToCheck = fullyQualifiedName.EndsWith(testName) ?
var nameToCheck = !fullyQualifiedName.Equals(testName, StringComparison.OrdinalIgnoreCase) && fullyQualifiedName.EndsWith(testName) ?
fullyQualifiedName.Substring(0, fullyQualifiedName.Length - testName.Length) :
fullyQualifiedName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ public void ToTestElementShouldNotFailWhenThereIsNoTestCategoreis()
CollectionAssert.AreEqual(expected, unitTestElement.TestCategories.ToArray());
}

[TestMethod]
public void ToTestElementShouldContainExpectedTestMethodPropertiesIfFqnIsSameAsTestName()
{
var expectedClassName = "TestProject1.Class1";
var fullyQualifiedName = expectedClassName + "." + "TestMethod1";
var testName = "TestProject1.Class1.TestMethod1";

ValidateTestMethodProperties(testName, fullyQualifiedName, expectedClassName);
}

[TestMethod]
public void ToTestElementShouldContainExpectedTestMethodPropertiesIfFqnEndsWithTestName()
{
Expand Down

0 comments on commit 06cf5cf

Please sign in to comment.