docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class UITestFixture

    Test fixture base class that creates a UI Toolkit panel without an EditorWindow.

    Inheritance
    object
    AbstractUITestFixture
    UITestFixture
    Inherited Members
    AbstractUITestFixture.AddTestComponent<T>()
    AbstractUITestFixture.RemoveTestComponent<T>()
    AbstractUITestFixture.panel
    AbstractUITestFixture.rootVisualElement
    AbstractUITestFixture.panelName
    AbstractUITestFixture.needsRendering
    AbstractUITestFixture.pixelsPerPoint
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.UIElements.TestFramework
    Assembly: Unity.UI.TestFramework.Runtime.dll
    Syntax
    public abstract class UITestFixture : AbstractUITestFixture
    Remarks

    Use this class when you can decouple the UI Toolkit content from an actual EditorWindow. To test with an EditorWindow, use EditorWindowUITestFixture<EditorWindowType>. To temporarily create an EditorWindow while developing or debugging tests, enable debugging mode by using UITestFixture(bool). In Play mode, this fixture runs as a RuntimeUITestFixture with a default runtime theme. Use themeStyleSheet to set the stylesheet.

    Constructors

    UITestFixture()

    Instantiates a UITestFixture using the AutoDetect functionality.

    Declaration
    protected UITestFixture()

    UITestFixture(bool)

    Instantiates a UITestFixture using the AutoDetect functionality.

    Declaration
    protected UITestFixture(bool debugMode)
    Parameters
    Type Name Description
    bool debugMode

    Enables debugging for tests.

    UITestFixture(FixtureType, bool)

    Instantiates a UITestFixture for the supplied fixtureType.

    Declaration
    protected UITestFixture(UITestFixture.FixtureType fixtureType, bool debugMode = false)
    Parameters
    Type Name Description
    UITestFixture.FixtureType fixtureType

    The type of test fixture to create.

    bool debugMode

    Enables debugging for tests.

    Exceptions
    Type Condition
    InvalidOperationException

    Throws when trying to create an Editor UITestFixture in the wrong setting.

    Properties

    clearContentAfterTest

    Clears the rootVisualElement after each test when set to true.

    Declaration
    public override sealed bool clearContentAfterTest { get; set; }
    Property Value
    Type Description
    bool
    Overrides
    AbstractUITestFixture.clearContentAfterTest

    debugMode

    Property which determines whether the window should remain open at the end of a failed test for debugging purposes. Default is false (off).

    Declaration
    public override sealed bool debugMode { get; set; }
    Property Value
    Type Description
    bool
    Overrides
    AbstractUITestFixture.debugMode
    Remarks

    Set this property to true if you want an editor window to remain open for manual debugging after a test failure. Tests in playmode will pause execution Should be set to false when running tests in batch mode.

    panelSize

    The size of the rootVisualElement of the panel.

    Declaration
    public override sealed Vector2 panelSize { get; set; }
    Property Value
    Type Description
    Vector2
    Overrides
    AbstractUITestFixture.panelSize

    simulate

    Returns the PanelSimulator used by the test fixture.

    Declaration
    public override sealed PanelSimulator simulate { get; set; }
    Property Value
    Type Description
    PanelSimulator
    Overrides
    AbstractUITestFixture.simulate
    Remarks

    Use this property to interact with the simulated panel.

    themeStyleSheet

    Theme style sheet used by this test fixture.

    Declaration
    public override sealed ThemeStyleSheet themeStyleSheet { get; set; }
    Property Value
    Type Description
    ThemeStyleSheet
    Overrides
    AbstractUITestFixture.themeStyleSheet
    Remarks

    Defaults to null. When the value is null, the style applied is the default theme style sheet.

    Methods

    AddTestComponent(UITestComponent)

    Adds the component to the test fixture.

    Declaration
    public override sealed void AddTestComponent(UITestComponent component)
    Parameters
    Type Name Description
    UITestComponent component

    The UITestComponent to add to the test fixture.

    Overrides
    AbstractUITestFixture.AddTestComponent(UITestComponent)
    Remarks

    Adding the component to the test fixture triggers relevant UITestComponent virtual methods based on the current test state.

    FindTestComponent<T>()

    Declaration
    public override sealed T FindTestComponent<T>()
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T
    Overrides
    AbstractUITestFixture.FindTestComponent<T>()

    FixtureOneTimeSetUp()

    Sets up the test fixture.

    Declaration
    public override void FixtureOneTimeSetUp()
    Overrides
    AbstractUITestFixture.FixtureOneTimeSetUp()

    FixtureOneTimeTearDown()

    Tears down the test fixture.

    Declaration
    public override void FixtureOneTimeTearDown()
    Overrides
    AbstractUITestFixture.FixtureOneTimeTearDown()

    FixtureSetUp()

    Sets up the test.

    Declaration
    public override void FixtureSetUp()
    Overrides
    AbstractUITestFixture.FixtureSetUp()

    FixtureTearDown()

    Tears down the test.

    Declaration
    public override void FixtureTearDown()
    Overrides
    AbstractUITestFixture.FixtureTearDown()

    FixtureUnitySetUp()

    Sets up the test using coroutines.

    Declaration
    public override IEnumerator FixtureUnitySetUp()
    Returns
    Type Description
    IEnumerator

    An IEnumerator for yield instructions

    Overrides
    AbstractUITestFixture.FixtureUnitySetUp()

    FixtureUnityTearDown()

    Tears down the test using coroutines.

    Declaration
    public override IEnumerator FixtureUnityTearDown()
    Returns
    Type Description
    IEnumerator

    An IEnumerator for yield instructions

    Overrides
    AbstractUITestFixture.FixtureUnityTearDown()

    RecreatePanel()

    Recreates the simulated UI Toolkit panel, providing a fresh instance.

    Declaration
    public override sealed void RecreatePanel()
    Overrides
    AbstractUITestFixture.RecreatePanel()

    ReleasePanel()

    Releases the currently simulated UI Toolkit panel.

    Declaration
    public override sealed void ReleasePanel()
    Overrides
    AbstractUITestFixture.ReleasePanel()

    RemoveTestComponent(UITestComponent)

    Removes the component from the test fixture.

    Declaration
    public override sealed void RemoveTestComponent(UITestComponent component)
    Parameters
    Type Name Description
    UITestComponent component

    The UITestComponent to remove from the test fixture.

    Overrides
    AbstractUITestFixture.RemoveTestComponent(UITestComponent)
    Remarks

    Removing the component from the test fixture triggers relevant UITestComponent virtual methods based on the current test state.

    In This Article
    Back to top
    Copyright © 2025 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)