Skip to content

Commit

Permalink
Unit test display name issue fixed. (#795)
Browse files Browse the repository at this point in the history
Fixes #793

Partially reverts changes introduced in #766
  • Loading branch information
Haplois authored Mar 10, 2021
1 parent 5dafe82 commit c3a4c9f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/Adapter/MSTest.CoreAdapter/ObjectModel/UnitTestElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ public UnitTestElement(TestMethod testMethod)
/// <returns> An instance of <see cref="TestCase"/>. </returns>
internal TestCase ToTestCase()
{
string fullName = this.TestMethod.HasManagedMethodAndTypeProperties
? string.Format(CultureInfo.InvariantCulture, "{0}.{1}", this.TestMethod.ManagedTypeName, this.TestMethod.ManagedMethodName)
: string.Format(CultureInfo.InvariantCulture, "{0}.{1}", this.TestMethod.FullClassName, this.TestMethod.Name);
// This causes compatibility problems with older runners.
// string fullName = this.TestMethod.HasManagedMethodAndTypeProperties
// ? string.Format(CultureInfo.InvariantCulture, "{0}.{1}", this.TestMethod.ManagedTypeName, this.TestMethod.ManagedMethodName)
// : string.Format(CultureInfo.InvariantCulture, "{0}.{1}", this.TestMethod.FullClassName, this.TestMethod.Name);
var fullName = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", this.TestMethod.FullClassName, this.TestMethod.Name);

TestCase testCase = new TestCase(fullName, TestAdapter.Constants.ExecutorUri, this.TestMethod.AssemblyName);
testCase.DisplayName = this.GetDisplayName();
Expand Down Expand Up @@ -195,9 +197,12 @@ private string GetDisplayName()
{
if (string.IsNullOrWhiteSpace(this.DisplayName))
{
return string.IsNullOrWhiteSpace(this.TestMethod.ManagedMethodName)
? this.TestMethod.Name
: this.TestMethod.ManagedMethodName;
return this.TestMethod.Name;

// This causes compatibility problems with older runners.
// return string.IsNullOrWhiteSpace(this.TestMethod.ManagedMethodName)
// ? this.TestMethod.Name
// : this.TestMethod.ManagedMethodName;
}
else
{
Expand Down

0 comments on commit c3a4c9f

Please sign in to comment.