Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Bug Bugs with Parameterized Test Fixtures

Discussion in 'Testing & Automation' started by YVR_Unity, Feb 19, 2022.

  1. YVR_Unity


    Jun 17, 2021
    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:
    Code (CSharp):
    1. namespace Test
    2. {
    3.     [TestFixture]
    4.     [TestFixture("hello", "hello", "goodbye")]
    5.     [TestFixture("zip", "zip")]
    6.     [TestFixture(42, 42, 99)]
    7.     public class ParameterizedTestFixture
    8.     {
    9.      // .....
    10.     }
    11. }
    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?

    Attached Files:

  2. sbergen


    Jan 12, 2015
    This looks like it could be a code stripping issue, which happens because the constructor will be called through reflection. You could try adding
    to the constructors to see if that would help.
  3. YVR_Unity


    Jun 17, 2021
    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?
    Thunderik likes this.
  4. RobertClose


    Nov 9, 2020
    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???