docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Test UI with Editor window instances

    If your tests require an actual EditorWindow instance, use EditorWindowUITestFixture to create tests that spawn and manage an EditorWindow instance. With this fixture, an Editor panel attached to a real EditorWindow hosts your UI, so the UI is rendered and visible on the screen during testing.

    Note

    To test your UXML or your custom control, use UITestFixture.

    The following example shows how to set up your test class to use EditorWindowUITestFixture:

    public class BasicEditorWindowExample : EditorWindowUITestFixture<UITestFrameworkDocSampleWindow>
    {
        [Test]
        public void EditorWindowTest()
        {
            // Ensure the window's UI is up to date.
            simulate.FrameUpdate();
    
            // Use the rootVisualElement property to query for elements
            // within the window created by the test fixture.
            Button button = rootVisualElement.Q<Button>("MyButton");
            Assert.That(button, Is.Not.Null);
    
            // Test steps.
            // ...
        }
    
    }
    

    Additional resources

    • Choose the appropriate test fixture
    • EditorWindow
    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)