TestFixtureSource doesn't work with test runner

Our project is using Unity 2018.4.0f1, so i don’t have access to UTF (the one that is packaged via UPM).

I want to set up a parameterized TestFixture but it does not work - the fixture never shows up in the test runner window.

My test class (fixture) should receive a string parameter (denoting a path to a prefab), load that prefab and execute different tests on it.

Here’s a (simplified) example of the code i’m trying to use. Nothing shows up in the test runner window:

using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEditor;
using UnityEngine;

namespace Tests.ContentValidation
{
    [TestFixture]
    [TestFixtureSource(typeof(VillagePrefabProvider))]
    public class VillagePrefabTests
    {
        private readonly GameObject villagePrefabPath;

        public VillagePrefabTests(string villagePrefabPath)
        {
            var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(villagePrefabPath);
            this.villagePrefabPath = Object.Instantiate(prefab);
        }

        [Test]
        public void TestSomething()
        {
        }

        [Test]
        public void TestAnotherThing()
        {
        }
    }

    public class VillagePrefabProvider : IEnumerable<string>
    {
        private const string PREFAB_ROOT = "Assets/Prefabs/Tests";

        public IEnumerator<string> GetEnumerator()
        {
            var guids = AssetDatabase.FindAssets("t:prefab", new[] { PREFAB_ROOT });

            foreach (var guid in guids)
            {
                yield return AssetDatabase.GUIDToAssetPath(guid);
            }
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
}

BTW i just tested the same code now on Unity 2019.3, the tests show up in the test runner window.

Bump? @superpig or anyone from the team? should this be supported?

The fixture is in a namespace, like in your example?

@superpig i’m such a noob… the test appeared in the test tree with the namespace so i had to look them up in a different place hahaha :slight_smile:

On another note - can i modify the displayed test name? the path is just too long and gets truncated.

Yes, I believe the standard NUnit mechanisms for setting test names should work. This is also a useful doc.