Search code examples
androidandroid-studiointellij-ideapluginsautomated-tests

Can I make UI test for Android Studio IDE plugin?


I want to create UI automation test for an android studio ide plugin. I searched this question. I have found this https://github.com/JetBrains/intellij-ui-test-robot repo. There is an example plugin project and ui test example for this plugin project. We can run a test intellij ide with this library. (with this command "./gradlew ui-test-example:clean ui-test-example:runIdeForUiTests & ./gradlew ui-test-example:test")

buildscript {
repositories {
    mavenCentral()
 }
}
plugins {
 id 'org.jetbrains.intellij'
 id 'org.jetbrains.kotlin.jvm'
 id 'java'
}

repositories {
  mavenCentral()
  maven { url = "https://packages.jetbrains.team/maven/p/ij/intellij-dependencies" }
}


def remoteRobotVersion = "0.11.20"

kotlin {
 jvmToolchain(17)
}

dependencies {
 testImplementation 'com.intellij.remoterobot:remote-robot:' + remoteRobotVersion
 testImplementation 'com.intellij.remoterobot:remote-fixtures:' + remoteRobotVersion
 testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
 testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
 testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.10.0'


 // Logging Network Calls
 testImplementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'

 // Video Recording
 implementation 'com.automation-remarks:video-recorder-junit5:2.0'
}


intellij {
 version.set('LATEST-EAP-SNAPSHOT')

}

downloadRobotServerPlugin {
 version.set(remoteRobotVersion)
}


runIdeForUiTests {
//    In case your Idea is launched on remote machine you can enable public port and enable 
 encryption of JS calls
//    systemProperty "robot-server.host.public", "true"
//    systemProperty "robot.encryption.enabled", "true"
//    systemProperty "robot.encryption.password", "my super secret"

systemProperty "robot-server.port", "8082"
systemProperty "ide.mac.message.dialogs.as.sheets", "false"
systemProperty "jb.privacy.policy.text", "<!--999.999-->"
systemProperty "jb.consents.confirmation.enabled", "false"
systemProperty "ide.mac.file.chooser.native", "false"
systemProperty "jbScreenMenuBar.enabled", "false"
systemProperty "apple.laf.useScreenMenuBar", "false"
systemProperty "idea.trust.all.projects", "true"
systemProperty "ide.show.tips.on.startup.default.value", "false"
//    systemProperty "eap.require.license", "true"
}

test {
// enable here nad in runIdeForUiTests block - to log the retrofit HTTP calls
// systemProperty "debug-retrofit", "enable"

// enable encryption on test side when use remote machine
// systemProperty "robot.encryption.password", "my super secret"
useJUnitPlatform()
}

But in my case I need to run an android studio ide with my plugin for test. Is it possible with this library ? Or do you have any different idea or solition for my question ? Please, help me.

Thanks in advance. :)


Solution

  • Yes, It is possible with "intellij-ui-test-robot".

    We have to set the intellij property like this.

    intellij {
    //We can set the  Android Studio build snapshot number for "version" attribute. 
    version.set("AI-211.7628.21.2111.8309675")
    //Or we can use the "localPath" attribute.  
    localPath.set("D:/Program Files/Android/Android Studio")
    }
    

    Also, You can find details about these attributes from here.