Driver ui tests

From JetBrains/intellij-community · View interactive version

Driver ui tests is an AI agent skill from the GitHub repository JetBrains/intellij-community. Write IntelliJ UI tests with IDE Starter or UI Driver, or run one off-screen to verify a change.

How to use this skill

Skill file

Driver UI Tests Guide

Three files sit next to this one. Read find-elements.md when you look for a component or read

the IDE state. Read api.md when you need the call for an action, a wait or a startup flag. Read

debug.md when a test fails.

Critical Rules

Where to look

A test uses JUnit 6 with the IDE Starter framework and the UI Driver framework:

| What you need | Where it is |

|---|---|

| The Driver framework | community/platform/remote-driver |

| Common UI components | community/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/ui |

| UI test examples | tests/remote-driver-tests |

| Runnable examples of each rule here | tests/intellij.ide.starter.extended/tests/com/intellij/ide/starter/extended/docexamples |

| The test case of a project, a com.intellij.ide.starter.models.TestCase | a *Cases.kt or a *CachedProjects.kt of the product, such as tests/intellij.ide.starter.extended.idea.ultimate/src/com/intellij/ide/starter/extended/idea/ultimate/CachedProjects.kt |

| The IDE a test runs against | the *ProductInit.kt of the product, such as community/tools/intellij.tools.ide.starter.product.idea.ultimate/src/com/intellij/tools/ide/starter/product/idea/ultimate/IdeaUltimateProductInit.kt |

| The annotations of a test | tests/intellij.ide.starter.allure.annotations/src/com/intellij/ide/starter/extended/allure/Annotations.kt |

Required Annotations

Every UI test must have the following annotations at the class level:

| Annotation | Purpose | TestOps Custom Field |

|------------|---------|---------------------|

| @Subsystems.* | Categorizes the test by subsystem | Subsystem |

| @Features.* | Specifies the feature being tested | Feature |

| @Components.* | Identifies the component under test | Component |

For tests linked to TestOps test cases, also add @AllureId("test_case_id") on the test method. The annotation

values should match the corresponding TestOps custom fields (Subsystem, Feature, Component).

Test Structure

Write one call chain from the context to useDriverAndCloseIde. Do not keep the context in a variable, and do not

keep a BackgroundRun or a Driver in a field. A kept context invites a second launch over project files that no

call rewound. A local val run = ...runIdeWithDriver() is correct when the test calls run.restart(), because

restart() needs that run.

pauseOnIndicators waits for the indicators before each Driver call, so it also prevents a failure in the middle

of the test. Pass it to runIdeWithDriver, and write no waitForIndicators in the test.

@Subsystems.Java
@Features.Completion
@Components.Editor
class MyTest {

    @Test
    @AllureId("123456")  // Required if test case exists in TestOps
    fun `my test name`() {
        Starter.newContext(ideInfo = IdeInfo.IdeaUltimate) { project = myProject }
            .applyVMOptionsPatch {
                addSystemProperty("ide.ui.non.modal.settings.window", "true")
            }
            .runIdeWithDriver(pauseOnIndicators = 5.minutes)
            .useDriverAndCloseIde {
                ideFrame {
                    openFile("src/Main.java")

                    step("Step description") {
                        // Test actions here
                    }
                }
            }
    }
}

applyVMOptionsPatch is safe here because the context is a fresh one for this test. Never patch a cached or a

shared context: the change would reach every test that reuses it.

Two cases need more than the pause:

waits up to 15 s for its component, and openFile waits for the project frame, but an action that opens a modal

dialog, a call such as singleProject(), and a key press all run at once. Put waitForProjectOpen(Timeouts.M)

before such a call, and after the test opens or reopens a project.

@OptIn(ManualWaitForIndicators::class). The compiler warns about each other manual wait.

Running Tests from Terminal

Driver tests require a fully built IDE. The tests.cmd script builds the IDE from sources and runs the tests.

Run each local test with USE_DOCKER_CONTAINER=true. The container gives a screen of its own, so the test does not

lose the focus to your desktop, and the environment matches the build agent:

USE_DOCKER_CONTAINER=true ./tests.cmd \
  --module intellij.driver.tests.java \
  --test com.intellij.driver.tests.idea.java.navigationTests.FindAndGoToTest

Key parameters:

After the run in the container passes, run the test once without the flag. Some failures come up in one

environment only. To keep the focus in that run, use the hidden desktop, see references/hidden-desktop.md.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.