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.
// ...
}
}