docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class AbstractUITestFixture

    Common interface for UI test fixtures. Manages NUnit's lifetime and provides a PanelSimulator to simulate interactions with UIToolkit content. Provides component-based extensibility for re-usable utilities. Actual usage done via UITestFixture, EditorWindowUITestFixture<EditorWindowType>, or RuntimeUITestFixture.

    Inheritance
    object
    AbstractUITestFixture
    CommonUITestFixture
    UITestFixture
    Inherited Members
    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 AbstractUITestFixture

    Properties

    clearContentAfterTest

    When set to true, the rootVisualElement will be cleared after each test.

    Declaration
    public abstract bool clearContentAfterTest { get; set; }
    Property Value
    Type Description
    bool

    needsRendering

    Set this to true if the tested elements require ImmediateModeElement rendering or an IMGUIContainer's OnGUI() logic that requires a repaint event. Defaults to false.

    Declaration
    public bool needsRendering { get; set; }
    Property Value
    Type Description
    bool

    panel

    The panel associated to the instance of PanelSimulator.

    Declaration
    public IPanel panel { get; }
    Property Value
    Type Description
    IPanel

    panelName

    Returns the name of the panel.

    Declaration
    public string panelName { get; }
    Property Value
    Type Description
    string

    panelSize

    The size of the root VisualElement of the panel.

    Declaration
    public abstract Vector2 panelSize { get; set; }
    Property Value
    Type Description
    Vector2

    pixelsPerPoint

    The pixels per point scalking factor of the panel. Defaults to 1.

    Declaration
    public float pixelsPerPoint { get; set; }
    Property Value
    Type Description
    float

    rootVisualElement

    The effective root VisualElement of the panel.

    Declaration
    public VisualElement rootVisualElement { get; }
    Property Value
    Type Description
    VisualElement
    Remarks

    Use this property to add elements to or query the UI of the panel.

    simulate

    Returns the PanelSimulator used by the test fixture.

    Declaration
    public abstract PanelSimulator simulate { get; set; }
    Property Value
    Type Description
    PanelSimulator
    Remarks

    Use this property to interact with the simulated panel.

    themeStyleSheet

    Theme style sheet used by this test fixture.

    Declaration
    public abstract ThemeStyleSheet themeStyleSheet { get; set; }
    Property Value
    Type Description
    ThemeStyleSheet
    Remarks

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

    Methods

    AddTestComponent(UITestComponent)

    Adds the component to the test fixture.

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

    The UITestComponent to add to the test fixture.

    Remarks

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

    AddTestComponent<T>()

    Creates and adds a UITestComponent to the test fixture.

    Declaration
    public T AddTestComponent<T>() where T : UITestComponent, new()
    Returns
    Type Description
    T

    The added test component.

    Type Parameters
    Name Description
    T

    The type of UITestComponent to attach to the test fixture.

    FindTestComponent<T>()

    Returns the first component of type T attached to the test fixture.

    Declaration
    public abstract T FindTestComponent<T>()
    Returns
    Type Description
    T

    The first component of type T.

    Type Parameters
    Name Description
    T

    The type of UITestComponent to search for.

    FixtureOneTimeSetUp()

    Sets up the test fixture.

    Declaration
    [OneTimeSetUp]
    public abstract void FixtureOneTimeSetUp()

    FixtureOneTimeTearDown()

    Tears down the test fixture.

    Declaration
    [OneTimeTearDown]
    public abstract void FixtureOneTimeTearDown()

    FixtureSetUp()

    Sets up the test.

    Declaration
    [SetUp]
    public abstract void FixtureSetUp()

    FixtureTearDown()

    Tears down the test.

    Declaration
    [TearDown]
    public abstract void FixtureTearDown()

    RecreatePanel()

    Recreates the simulated UIToolkit panel, providing a fresh instance.

    Declaration
    public abstract void RecreatePanel()

    ReleasePanel()

    Releases the currently simulated UIToolkit panel.

    Declaration
    public abstract void ReleasePanel()

    RemoveTestComponent(UITestComponent)

    Removes the component from the test fixture.

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

    The UITestComponent to remove from the test fixture.

    Remarks

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

    RemoveTestComponent<T>()

    Finds and removes the first component of type T from the test fixture.

    Declaration
    public void RemoveTestComponent<T>() where T : UITestComponent
    Type Parameters
    Name Description
    T

    The type of UITestComponent to search for and remove.

    Remarks

    Does nothing if a test component of the specified type T is not found.

    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)