Skip to content
zcervink edited this page Oct 27, 2021 · 67 revisions

Welcome to the IntelliJ IDEA UI test library wiki! Here you'll find several pieces of information and advices on how to setup, use and contribute to this library.

Purpose of this project

This project allows you to create automated UI tests for your IntelliJ IDEA plugin. Using this project you are able to access UI elements such as buttons, inputs, item trees elements etc. and perform actions with them. Navigating through wizards, clicking on buttons or editing file content of newly created project could be automated using this project.

Any Suggestions or Questions?

Please submit an issue to this project.

Contributing

Feel free to contribute to this project! See the contribution guide for more details.

Quick setup

The setup of this library is easy - just extend the build.gradle file as described in the following steps:

STEP #1: Adding repositories

You need to add the following nexus and JetBrains repositories to access dependencies needed to run UI tests:

repositories {
    maven {
        url 'https://repository.jboss.org/nexus/content/repositories/snapshots'
    }
    maven {
        url 'https://repository.jboss.org/nexus/content/groups/public'
    }
    maven {
        url 'https://packages.jetbrains.team/maven/p/ij/intellij-dependencies'
    }
}

STEP #2: Adding dependencies

Add the following dependency:

dependencies {
    compile 'com.redhat.devtools.intellij:intellij-common-ui-test-library:0.0.3'
}

STEP #3: Adding source sets

The following source set is needed to define where in your project will be your UI tests and resources located. The following example displays the 'src/it/java' location for java code of UI tests and the 'src/it/resources' location for resources:

sourceSets {
    integrationTest {
        java.srcDir file('src/it/java')
        resources.srcDir file('src/it/resources')
        compileClasspath += sourceSets.main.output + configurations.testRuntime
        runtimeClasspath += output + compileClasspath
    }
}

STEP #4: Adding tasks

task integrationTest(type: Test) {
    useJUnitPlatform()
    description = 'Runs the integration tests.'
    group = 'verification'
    testClassesDirs = sourceSets.integrationTest.output.classesDirs
    classpath = sourceSets.integrationTest.runtimeClasspath
    outputs.upToDateWhen { false }
    mustRunAfter test
}

runIdeForUiTests {
    systemProperty "robot-server.port", System.getProperty("robot-server.port")
}

Start and quit IntelliJ IDEA

Use the following code to start IntelliJ before running the first UI test. The runIde() method not only starts the IDE for UI tests, it also returns reference to the Remote-Robot instance which will be useful later to access UI elements such as buttons, inputs etc.

private static RemoteRobot robot;

@BeforeAll
public static void runIdeForUiTests() {
    robot = UITestRunner.runIde(UITestRunner.IdeaVersion.V_2020_3, 8580);
}

After executing all the UI tests close the IDE by running the following command:

@AfterAll
public static void closeIde() {
    UITestRunner.closeIde();
}

What next? Implement your first UI test!

After you manage to setup this library to your project and successfully start and quit IntelliJ IDEA, there is no more setup needed. Just start writing your UI tests!

Create your first fixture

Create an instance of a FlatWelcomeFrame class to an object which allows you to access the 'Welcome to IntelliJ IDEA' dialog

FlatWelcomeFrame flatWelcomeFrame = remoteRobot.find(FlatWelcomeFrame.class, Duration.ofSeconds(10));

Use the fixture to access UI

After you have the object, it can be used to access the UI - here is an example of clicking on the 'New Project' button:

flatWelcomeFrame.createNewProject();

Use any tool provided by Remote-Robot framework

Besides the fixtures and utilities provided by this library you can use any tool from the Remote-Robot framework itself.

Clone this wiki locally