Class AbstractUITestFixture
Common interface for UI test fixtures.
Manages NUnit's lifetime and provides a PanelSimulator to simulate interactions with UI Toolkit content.
Provides component-based extensibility for reusable utilities.
Actual usage done via UITestFixture,
EditorWindowUITestFixture<EditorWindowType>,
or RuntimeUITestFixture.
Inherited Members
Namespace: UnityEngine.UIElements.TestFramework
Assembly: Unity.UI.TestFramework.Runtime.dll
Syntax
public abstract class AbstractUITestFixture
Properties
clearContentAfterTest
Clears the rootVisualElement after each test when set to true.
Declaration
public abstract bool clearContentAfterTest { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
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 abstract bool debugMode { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
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.
needsRendering
Set 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 rootVisualElement of the panel.
Declaration
public abstract Vector2 panelSize { get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
pixelsPerPoint
The pixels per point scaling factor of the panel.
Defaults to 1.
Declaration
public float pixelsPerPoint { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
rootVisualElement
The effective rootVisualElement 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 is 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 |
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 |
Type Parameters
| Name | Description |
|---|---|
| T | The type of |
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()
FixtureUnitySetUp()
Sets up the test using coroutines.
Declaration
public abstract IEnumerator FixtureUnitySetUp()
Returns
| Type | Description |
|---|---|
| IEnumerator | An IEnumerator for yield instructions |
FixtureUnityTearDown()
Tears down the test using coroutines.
Declaration
public abstract IEnumerator FixtureUnityTearDown()
Returns
| Type | Description |
|---|---|
| IEnumerator | An IEnumerator for yield instructions |
RecreatePanel()
Recreates the simulated UI Toolkit panel, providing a fresh instance.
Declaration
public abstract void RecreatePanel()
ReleasePanel()
Releases the currently simulated UI Toolkit 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 |
Remarks
Removing the component from the test fixture triggers relevant
UITestComponent virtual methods based 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 |
Remarks
Does nothing if a test component of the specified type T is not found.