Skip to content

Quick setup

Richard Kocián (rkocian) edited this page Apr 21, 2024 · 4 revisions

The setup of this library is easy - just extend the build.gradle file as described in the following steps and you are ready to write your first UI test.

STEP #1: Adding repositories

You need to add the following nexus and JetBrains repositories:

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.3.1-SNAPSHOT'
}

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")
}

STEP #5: Test project location

Developers can specify the location where the test project will be created by providing a system property called testProjectLocation. For example:

task integrationTest(type: Test) {
    ...
    systemProperties['testProjectLocation'] = '/home/user/IdeaProjects/intellij-ui-test-projects/'
    ...
}

Or add the location as a paramater for gradlew command which runs the test. For example:

systemProperties['testProjectLocation'] = project.hasProperty('testProjectLocation') ? project.property('testProjectLocation') : null
    
./gradlew integrationTest -PtestProjectLocation=${env.HOME}/IdeaProjects/intellij-ui-test-projects/

Remote-robot IntelliJ instance logs

If developers want to view the remote-robot intellij instance logs, they can specify system property intellij_debug to save these logs to files, which will be stored inside $user.dir/intellij_debug folder.

task integrationTest(type: Test) {
    ...
    systemProperties['intellij_debug'] = 'true'
    ...
}
Clone this wiki locally