Debug UI test fixtures
The UI test fixtures manage, set up, and tear down the panel tracked by the fixtures. By default, the UI isn't visible because the fixture creates a panel that's not attached to an EditorWindow. As a result, the UI isn't rendered during test execution. You might need to visualize the UI during test execution to inspect its state. This is especially useful when a test fails, as it allows you to view the UI as it was at the point of failure.
This section describes how to debug tests that use EditorWindowUITestFixture or UITestFixture to visualize the UI when a test fails, or when you want to inspect the UI during test execution.
Note
Debugging for RuntimeUITestFixture isn't supported in the current version.
Debug a test that uses EditorWindowUITestFixture
To debug a test that inherits from EditorWindowUITestFixture, set debugMode to true within the code.
public class EditorWindowDebugging : EditorWindowUITestFixture<UITestFrameworkDocSampleWindow>
{
[Test]
public void TestToDebug()
{
// Set debugMode to true for the test
// you are currently writing or debugging.
debugMode = true;
// Test steps.
// ...
// The UI will remain open and visible when the test fails.
// Assert.Fail();
}
}
Debug a test that uses UITestFixture
You can debug a test that inherits from UITestFixture in two ways:
- Change the base class to
DebugUITestFixture. - Pass a debug value to the
UITestFixtureconstructor.
Change the base class
If your Editor test inherits directly from UITestFixture, you can temporarily change the base class to DebugUITestFixture within the code:
public class EditorDebugging : DebugUITestFixture
{
// You can easily temporarily switch the base class
// from UITestFixture to DebugUITestFixture to enable debugging.
[Test]
public void TestToDebug()
{
// Test steps.
// The UI will remain open and visible when the test fails.
// Assert.Fail();
}
}
Pass a debug value to the constructor
If your Editor test inherits from a runtime test class, which inherits from UITestFixture (such as this example), you can temporarily pass a value to the base class' constructor to enable debug mode.
// This class is contained in a runtime test assembly.
public class UITestFixture_RuntimeBase : UITestFixture
{
public UITestFixture_RuntimeBase() : base(debugMode: true) { }
}
// This class is contained in an Editor test assembly.
public class RuntimeBase_EditorDebugging : UITestFixture_RuntimeBase
{
// This test class will run in DebugMode because its base
// class passes the debugMode parameter to the UITestFixture constructor.
[Test]
public void TestToDebug()
{
// Test steps.
// The UI will remain open and visible when the test fails.
// Assert.Fail();
}
}