Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Bug Cannot run playmode tests in sequence with MRTK.

Discussion in 'Testing & Automation' started by Tierna_Lawless, Feb 13, 2024.

  1. Tierna_Lawless

    Tierna_Lawless

    Joined:
    Jan 5, 2023
    Posts:
    3
    Versions:
    Microsoft Mixed Reality Toolkit 2.8.3
    Unity 2022.3.4f1

    I am having issues running playmode tests in sequence (calling run tests on a entire testing environment). This is causing issues when automating tests.

    When each test suite is run individually, each test case runs and passes appropriately.

    upload_2024-2-13_11-46-22.png

    My tests run by using [OneTimeSetUp] to call LoadScene.

    When running the testing, the first test suite always runs appropriately but after [OneTimeSetup] calls LoadScene in the next suite, it breaks and starts spitting out errors.

    What seems to be the problem is that MRTK does not properly dispose of itself between tests. I want to find a way to properly dispose of MRTK in between scenes so that i can run my test suites programmatically.

    Notes about errors:
    - In first test suite, we get no errors and it runs appropriately.
    - In last test suite, we get UpdateMousePointerEventData error + an error from MRTK OnDestroy()
    - In middle test suites, we get UpdateMousePointerEventData error, an error from MRTK Awake(), OnDisable() and OnDestroy().

    Errors:
    Code (CSharp):
    1.  
    2. [B]// multiple of these errors identical from each failed suite.[/B]
    3. NullReferenceException: Object reference not set to an instance of an object
    4. Microsoft.MixedReality.Toolkit.Input.MixedRealityInputModule.UpdateMousePointerEventData (Microsoft.MixedReality.Toolkit.Input.MixedRealityInputModule+PointerData pointerData) (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Services/InputSystem/MixedRealityInputModule.cs:251)
    5. Microsoft.MixedReality.Toolkit.Input.MixedRealityInputModule.GetMousePointerEventData (System.Int32 pointerId) (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Services/InputSystem/MixedRealityInputModule.cs:222)
    6. UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent (System.Int32 id) (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/InputModules/StandaloneInputModule.cs:540)
    7. Microsoft.MixedReality.Toolkit.Input.MixedRealityInputModule.Process () (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Services/InputSystem/MixedRealityInputModule.cs:161)
    8. UnityEngine.EventSystems.EventSystem.Update () (at ./Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:530)
    9.  
    10. [B]// appears after every failed test suite. originates from MRTK onDestroy()[/B]
    11. NullReferenceException: Object reference not set to an instance of an object
    12. Microsoft.MixedReality.Toolkit.Input.MixedRealityInputSystem.Disable () (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Services/InputSystem/MixedRealityInputSystem.cs:363)
    13. Microsoft.MixedReality.Toolkit.MixedRealityToolkit.UnregisterService[T] (T serviceInstance) (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Core/Services/MixedRealityToolkit.cs:334)
    14. Microsoft.MixedReality.Toolkit.MixedRealityToolkit.UnregisterService[T] (System.String name) (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Core/Services/MixedRealityToolkit.cs:319)
    15. Microsoft.MixedReality.Toolkit.MixedRealityToolkit.DestroyAllServices () (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Core/Services/MixedRealityToolkit.cs:1118)
    16. [B]Microsoft.MixedReality.Toolkit.MixedRealityToolkit.UnregisterInstance[/B] (Microsoft.MixedReality.Toolkit.MixedRealityToolkit toolkitInstance) (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Core/Services/MixedRealityToolkit.cs:858)
    17. [B]Microsoft.MixedReality.Toolkit.MixedRealityToolkit.OnDestroy ()[/B] (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Core/Services/MixedRealityToolkit.cs:761)
    18.  
    19. [B]// appears after every failed test suite bar the last. originates from MRTK Awake()[/B]
    20. NullReferenceException: Object reference not set to an instance of an object
    21. Microsoft.MixedReality.Toolkit.Input.MixedRealityInputSystem.Disable () (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Services/InputSystem/MixedRealityInputSystem.cs:363)
    22. Microsoft.MixedReality.Toolkit.MixedRealityToolkit.UnregisterService[T] (T serviceInstance) (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Core/Services/MixedRealityToolkit.cs:334)
    23. Microsoft.MixedReality.Toolkit.MixedRealityToolkit.UnregisterService[T] (System.String name) (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Core/Services/MixedRealityToolkit.cs:319)
    24. Microsoft.MixedReality.Toolkit.MixedRealityToolkit.DestroyAllServices () (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Core/Services/MixedRealityToolkit.cs:1118)
    25. [B]Microsoft.MixedReality.Toolkit.MixedRealityToolkit.RegisterInstance[/B] (Microsoft.MixedReality.Toolkit.MixedRealityToolkit toolkitInstance, System.Boolean setAsActiveInstance) (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Core/Services/MixedRealityToolkit.cs:829)
    26. [B]Microsoft.MixedReality.Toolkit.MixedRealityToolkit.Awake () [/B](at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Core/Services/MixedRealityToolkit.cs:709)
    27.  
    28. [B]// appears after every failed test suite bar the last. originates from MRTK onDisable()[/B]
    29. NullReferenceException: Object reference not set to an instance of an object
    30. Microsoft.MixedReality.Toolkit.Input.MixedRealityInputSystem.Disable () (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Services/InputSystem/MixedRealityInputSystem.cs:363)
    31. Microsoft.MixedReality.Toolkit.MixedRealityToolkit+<>c.<DisableAllServices>b__75_0 (Microsoft.MixedReality.Toolkit.IMixedRealityService service) (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Core/Services/MixedRealityToolkit.cs:1084)
    32. Microsoft.MixedReality.Toolkit.MixedRealityToolkit.ExecuteOnAllServicesReverseOrder (System.Action`1[T] execute) (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Core/Services/MixedRealityToolkit.cs:1181)
    33. Microsoft.MixedReality.Toolkit.MixedRealityToolkit.DisableAllServices () (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Core/Services/MixedRealityToolkit.cs:1084)
    34. [B]Microsoft.MixedReality.Toolkit.MixedRealityToolkit.OnDisable ()[/B] (at ./Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@f2323a9b7aec/Core/Services/MixedRealityToolkit.cs:755)
    35.  
     
    Last edited: Feb 13, 2024