docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Debug UI test fixtures

    The UI test fixtures manage, set up, and tear down the panel tracked by the fixtures.

    UITestFixture applied to an Editor test creates a panel that isn't attached to an EditorWindow. Therefore, the UI isn't rendered on the screen during test execution and is therefore not visible. Tests that inherit from EditorWindowUITestFixture or RuntimeUITestFixture may have their UI rendered and visible on the screen.

    You might need to visualize your tests' UI during test development or execution to inspect its state. This is especially useful when a test fails, as it allows you to view the UI at the point of failure.

    Note

    Only enable debugMode temporarily while debugging, then remove it from your code. Debug mode suspends cleanup of certain states and can cause subsequent tests to fail if a test has already failed.

    When you set debugMode to true, the UI of your test stays active when the test fails.

    State management during debugging

    The UI test fixtures manage the state of your UI and the UITestComponent states.

    During debugging, the test fixtures don't clean up these states. Therefore, you must manually clean up the state after you finish debugging:

    • Editor tests: If the test fails, the Editor window remains open for debugging. To clean up, close the spawned Editor window if it's still present.
    • Play mode tests: If the test fails, the Game view enters Pause mode. To clean up, select the Pause button to resume Play mode.

    Debug a test that uses EditorWindowUITestFixture

    To debug a test that inherits from EditorWindowUITestFixture, set debugMode to true within the code.

    public class EditorWindowDebugging : EditorWindowUITestFixture<UITestFrameworkDocSampleWindow>
    {
        [Test]
        public void TestToDebug()
        {
            // Set debugMode to true for the test
            // you are currently writing or debugging.
            debugMode = true;
    
            // Test steps.
            // ...
    
            // The UI will remain open and visible when the test fails.
            // Assert.Fail();
        }
    }
    

    Debug a test that uses UITestFixture

    To debug a test that inherits from UITestFixture, you can temporarily pass a value to the UITestFixture constructor to enable debug mode.

    This example shows how to enable debugging for an Editor test that inherits from a runtime test class, which inherits from UITestFixture (such as this example).

    // This class is contained in a runtime test assembly.
    public class UITestFixture_RuntimeBase : UITestFixture
    {
        public UITestFixture_RuntimeBase() : base(debugMode: true) { }
    
        [Test]
        public void RuntimeTestToDebug()
        {
            // Test steps.
            // The UI will remain open and visible when the test fails.
            //Assert.Fail();
        }
    }
    
    // This class is contained in an Editor test assembly.
    public class RuntimeBase_EditorDebugging : UITestFixture_RuntimeBase
    {
        // This test class will run in DebugMode because its base
        // class passes the debugMode parameter to the UITestFixture constructor.
    
        [Test]
        public void TestToDebug()
        {
            // Test steps.
            // The UI will remain open and visible when the test fails.
            //Assert.Fail();
        }
    }
    

    Debug a test that uses RuntimeUITestFixture

    To debug a test that inherits from RuntimeUITestFixture, set debugMode to true within the code.

    public class RuntimeUITestFixture_Debugging : RuntimeUITestFixture
    {
        [Test]
        public void TestToDebug()
        {
            debugMode = true;
    
            // Test steps.
            // The UI will remain open and visible when the test fails.
            //Assert.Fail();
        }
    }
    

    Additional resources

    • Test in both Editor and runtime states
    • EditorWindow
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)