Cysharp/RuntimeUnitTestToolkit

TestCaseSource attribute is not parsed correctly

eliatlas opened this issue · 0 comments

The problem
This is the test in my project that doesn't work:

[UnityTest, TestCaseSource(nameof(CallGetTestCases))]
public IEnumerator ExecuteTests(string filePath) => UniTask.ToCoroutine(async () =>
{
    await BbTestsHelper.RunLinesTests(this, GetTestCasesFolder(), filePath);
});

The reason
RuntimeUnitTestToolkit/UnitTestData.cs doesn't parse this correctly.

My solution
Had to update List<object[]> GetTestData. Replaced this

foreach (var item2 in enumerator)
{
    var item3 = item2 as IEnumerable; // object[][]
    if (item3 != null)
    {
        var l = new List<object>();
        foreach (var item4 in item3)
        {
            l.Add(item4);
        }
        testCases.Add(l.ToArray());
    }
}

with this

  foreach (var item2 in enumerator)
  {
      var item3 = item2 as TestCaseData; // object[][]
      if (item3 != null)
      {
          testCases.Add(item3.Arguments);
      }
  }