Skip to content

Commit

Permalink
split dynamic tests with similar FullName and different childIndex (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
van800 authored Jun 12, 2019
1 parent 6137954 commit 44a0613
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions unity/EditorPlugin/AfterUnity56/UnitTesting/TestEventsSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,37 @@ internal static string GetIdFromNUnitTest(ITest test)
if (testMethod == null)
{
ourLogger.Verbose("{0} is not a TestMethod ", test.FullName);
return test.FullName;
return GetUniqueName(test);
}

return test.FullName;
return GetUniqueName(test);
}

// analog of UnityEngine.TestRunner.NUnitExtensions.TestExtensions.GetUniqueName
// I believe newer nunit has improved parameters presentation compared to the one used in Unity.
// https://github.com/nunit/nunit/blob/d56424858f97e19a5fe64905e42adf798ca655d1/src/NUnitFramework/framework/Internal/TestNameGenerator.cs#L223
// so once Unity updates its nunit, this hack would not be needed anymore
private static string GetUniqueName(ITest test)
{
string str = test.FullName;
if (HasChildIndex(test))
{
int childIndex = GetChildIndex(test);
if (childIndex >= 0)
str += childIndex;
}

return str;
}

private static int GetChildIndex(ITest test)
{
return (int) test.Properties["childIndex"][0];
}

private static bool HasChildIndex(ITest test)
{
return test.Properties["childIndex"].Count > 0;
}
}
}

0 comments on commit 44a0613

Please sign in to comment.