Test UI without Editor window dependencies
If your tests don't require an actual EditorWindow instance, use UITestFixture to create Editor tests that spawn and manage an empty Editor panel. This fixture doesn't create an EditorWindow instance, which allows for faster test execution. The Editor panel hosts your UI, but the UI isn't rendered or visible on the screen during testing.
Note
If your UI is defined in the CreateGUI() or requires a GUI view to work properly, use EditorWindowUITestFixture to spawn a real EditorWindow instance for your tests.
The following example shows how to set up your test class to use UITestFixture in an Editor test assembly:
// This class is contained in an Editor test assembly.
public class BasicEditorExample : UITestFixture
{
// This test class will spawn an EditorPanel that you
// can add UI elements to via the rootVisualElement property.
[Test]
public void EditorPanelTest()
{
// Use the rootVisualElement property to add elements
// to your UI.
rootVisualElement.Add(new Button() { name = "MyButton" });
// Ensure the panel's UI is up to date.
simulate.FrameUpdate();
Button button = rootVisualElement.Q<Button>("MyButton");
Assert.That(button, Is.Not.Null);
// Test steps.
// ...
}
}