Bugs with Parameterized Test Fixtures

I have made a parameterized test fixture in play mode which exactly the same with the demo code in nunit official documentation:TestFixture | NUnit Docs, as the attached file “ParameterizedTestFixture.cs”.

but he Unit Test Runner window shows error for this testfixture:

ParameterizedTestFixture (0.000s)

An exception was thrown while loading the test.
System.ArgumentNullException: pathName
Parameter name: Argument pathName must not be null

If i add a namespace for the testfixture, sth like:

namespace Test
{
    [TestFixture]
    [TestFixture("hello", "hello", "goodbye")]
    [TestFixture("zip", "zip")]
    [TestFixture(42, 42, 99)]
    public class ParameterizedTestFixture
    {
     // .....
    }
}

Then all tests work well in unity editor (still in play mode), but when i run tests in android platform, the following error occurred for every test:

No suitable constructor was found

How should i use parameterized test fixture in android platform?

7909018–1008397–ParameterizedTestFixture.cs (1.31 KB)

This looks like it could be a code stripping issue, which happens because the constructor will be called through reflection. You could try adding [Preserve] to the constructors to see if that would help.

Wow, Really thanks.

After adding [UnityEngine.Scripting.Preserve] attribute to all constructors, all tests passed in android platform.

But i am still curious about why i have to add namespace for parameterized test fixture?

1 Like

I came here to post about this after struggling about. I thought it was just that parameterised test fixtures were not supported, and that there was no documentation for this.

Completely surprised to find that it works when you put the test fixture under a namespace???

[Preserve] did not work for me, adding a the test class to a namespace fixed it.

I found this issue in nunit: