Hey,
I had a look around the forum but couldnt find the answer to this so creating a new post. I want to create some tests based on a dataset that is changing with each release. Hardcoding the tests wont work. In the past i have been able to generate the TestCaseData during the setup phase of testing however since there is an unknown time delay between requesting the data and it appearing I am hoping to now use the [UnitySetUp] which allows be to yield until the data is ready.
Ive created a simple code sample which has the same issues any help would be amazing;
As far as i can tell from documentation this should work so i must be missing something small/obvious!
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine.TestTools;
namespace Tests
{
[TestFixture(Category = "Database", Description = "Verify database data is accurate and valid")]
public class BasicUnitTestExample
{
public static List<TestCaseData> TestData;
[UnitySetUp]
public IEnumerator TestSetup()
{
//Wait for data to be loaded in background
yield return null;
//From data loaded create tests
TestData = new List<TestCaseData>();
//Mock test created
TestCaseData caseA = new TestCaseData("Hello");
caseA.SetName("A");
TestData.Add(caseA);
TestCaseData caseB = new TestCaseData("There");
caseB.SetName("B");
TestData.Add(caseB);
}
[Test, TestCaseSource(nameof(TestData))]
public void IsEmpty(string data)
{
Assert.IsTrue(string.IsNullOrEmpty(data));
}
}
}