Skip to content

Commit de9c3a5

Browse files
author
Uladzislau Kalesnikau
committed
Merge branch 'fix/IJMP-2061-ui-tests' into 'release/v2.1.0'
Working on UI tests fix See merge request ijmp/for-mainframe!621
2 parents 19ee167 + e782977 commit de9c3a5

39 files changed

+1161
-157
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
libs
1010
verifier-all.jar
11+
**/mock_project/idea.log
1112

1213
# Windows thumbnail cache files
1314
Thumbs.db
@@ -34,3 +35,5 @@ bin
3435
# Fleet files
3536
.fleet
3637
.editorconfig
38+
/out
39+
/allure-results

README.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,23 @@ We have two options of tests:
145145
\Program Files\Git\usr\bin\bash.exe" --login -i
146146
2. Make Java version 17 available from command line (add to PATH)
147147

148-
### To run UI tests:
148+
### To run UI tests (new):
149+
150+
Before running the tests, make sure you use the configuration after IntelliJ IDEA v2024.3.
151+
Just run `./gradlew uiTests` task, or use [Kotest](https://plugins.jetbrains.com/plugin/14080-kotest) plug-in for
152+
IntelliJ IDEA. The plug-in will provide the buttons against the test cases and suites in **src/uiTest** folder
153+
154+
### To run UI tests (old):
149155

150156
1. change values for ZOS_USERID, ZOS_PWD, CONNECTION_URL in src/uiTest/kotlin/auxiliary/utils.kt
151157
2. run ./gradlew buildPlugin in console
152-
4. run the script uiTest.sh
153-
5. once IdeForUiTests started make it as main window on the screen and do not touch mouse anymore
154-
6. on first launch a ide_for_launch folder will be created and ide will be downloaded
158+
3. run the script uiTest.sh
159+
4. once IdeForUiTests started make it as main window on the screen and do not touch mouse anymore
160+
5. on first launch ide_for_launch folder will be created and ide will be downloaded
155161

156162
UI tests results: build/reports/tests/uiTest/index.html
157163

158-
### To run smoke test:
164+
### To run smoke test (old):
159165

160166
1. change values for ZOS_USERID, ZOS_PWD, CONNECTION_URL in src/uiTest/kotlin/auxiliary/utils.kt
161167
2. run the script smokeTest.sh

build.gradle.kts

+138-138
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414

1515
import org.jetbrains.changelog.Changelog
1616
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
17+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
1718
import java.time.LocalDate
1819
import java.time.ZoneId
1920
import java.time.format.DateTimeFormatter
2021

22+
//!IMPORTANT!: to refer "libs", use ./gradle/libs.versions.toml
23+
2124
fun properties(key: String) = providers.gradleProperty(key)
2225
fun environment(key: String) = providers.environmentVariable(key)
2326
fun dateValue(pattern: String): String =
@@ -44,10 +47,17 @@ val plugins = listOf(
4447
PluginDescriptor(
4548
jvmTargetVersion = JavaVersion.VERSION_17,
4649
since = "233.11799",
47-
getUntil = { provider { "242.*" } },
50+
getUntil = { provider { "241.*" } },
4851
sdkVersion = "2023.3",
4952
sourceFolder = "IC-233"
5053
),
54+
PluginDescriptor(
55+
jvmTargetVersion = JavaVersion.VERSION_21,
56+
since = "242.20224",
57+
getUntil = { provider { "242.*" } },
58+
sdkVersion = "2024.2",
59+
sourceFolder = "IC-242"
60+
),
5161
PluginDescriptor(
5262
jvmTargetVersion = JavaVersion.VERSION_21,
5363
since = "243.12818",
@@ -61,23 +71,14 @@ val descriptor = plugins.first { it.sourceFolder == productName }
6171

6272
group = properties("pluginGroup").get()
6373
version = properties("pluginVersion").get()
64-
val remoteRobotVersion = "0.11.23"
65-
val okHttp3Version = "4.12.0"
66-
val kotestVersion = "5.9.1"
67-
val retrofit2Vertion = "2.11.0"
68-
val junitVersion = "5.11.1"
69-
val mockkVersion = "1.13.12"
70-
val jGraphTVersion = "1.5.2"
71-
val zoweKotlinSdkVersion = "0.5.0"
72-
val javaAnalyticsVersion = "3.5.1"
7374

7475
plugins {
75-
id("org.jetbrains.intellij.platform") version "2.1.0"
76-
id("org.jetbrains.changelog") version "2.2.1"
77-
kotlin("jvm") version "1.9.22"
76+
alias(libs.plugins.gradle) // IntelliJ Platform Gradle Plugin
77+
alias(libs.plugins.kotlinJvm)
78+
alias(libs.plugins.changelog)
79+
alias(libs.plugins.kover)
80+
alias(libs.plugins.dependencycheck)
7881
java
79-
id("org.jetbrains.kotlinx.kover") version "0.8.3"
80-
id("org.owasp.dependencycheck") version "10.0.4"
8182
}
8283

8384
repositories {
@@ -108,6 +109,25 @@ kotlin {
108109
}
109110
}
110111

112+
/** Source sets configuration */
113+
sourceSets {
114+
main {
115+
java {
116+
srcDir("src/${descriptor.sourceFolder}/kotlin")
117+
}
118+
resources {
119+
srcDir("src/${descriptor.sourceFolder}/resources")
120+
}
121+
}
122+
create("uiTest") {
123+
compileClasspath += sourceSets.main.get().compileClasspath + sourceSets.test.get().compileClasspath
124+
runtimeClasspath += output + compileClasspath
125+
}
126+
}
127+
128+
configurations["uiTestRuntimeOnly"].extendsFrom(configurations.testRuntimeOnly.get())
129+
configurations["uiTestImplementation"].extendsFrom(configurations.testImplementation.get())
130+
111131
dependencies {
112132
intellijPlatform {
113133
// intellijIdeaCommunity(descriptor.sdkVersion)
@@ -116,27 +136,18 @@ dependencies {
116136
jetbrainsRuntime()
117137
instrumentationTools()
118138
testFramework(TestFrameworkType.Plugin.Java)
139+
testFramework(TestFrameworkType.Starter, configurationName = "uiTestImplementation")
119140
}
120-
implementation(group = "com.squareup.retrofit2", name = "retrofit", version = retrofit2Vertion)
121-
implementation("com.squareup.retrofit2:converter-gson:$retrofit2Vertion")
122-
implementation("com.squareup.retrofit2:converter-scalars:$retrofit2Vertion")
123-
implementation("com.squareup.okhttp3:okhttp:$okHttp3Version")
124-
implementation("org.jgrapht:jgrapht-core:$jGraphTVersion")
125-
implementation("org.zowe.sdk:zowe-kotlin-sdk:$zoweKotlinSdkVersion")
126-
implementation("com.segment.analytics.java:analytics:$javaAnalyticsVersion")
127-
implementation("org.junit.jupiter:junit-jupiter-params:$junitVersion")
128-
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
129-
testImplementation("io.mockk:mockk:$mockkVersion")
130-
testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")
131-
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
132-
testImplementation("com.intellij.remoterobot:remote-robot:$remoteRobotVersion")
133-
testImplementation("com.intellij.remoterobot:remote-fixtures:$remoteRobotVersion")
134-
testImplementation("com.squareup.okhttp3:mockwebserver:$okHttp3Version")
135-
testImplementation("com.squareup.okhttp3:okhttp-tls:$okHttp3Version")
136-
testImplementation("com.squareup.okhttp3:logging-interceptor:$okHttp3Version")
137-
testImplementation("com.intellij.remoterobot:ide-launcher:$remoteRobotVersion")
138-
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
139-
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:$junitVersion")
141+
implementation(libs.retrofit2)
142+
implementation(libs.retrofit2.converter.gson)
143+
implementation(libs.retrofit2.converter.scalars)
144+
implementation(libs.okhttp3)
145+
implementation(libs.jgrapht.core)
146+
implementation(libs.zowe.kotlin.sdk)
147+
implementation(libs.segment.analytics)
148+
testImplementation(libs.mockk)
149+
testImplementation(libs.kotest.assertions.core)
150+
testImplementation(libs.kotest.runner.junit5)
140151
}
141152

142153
intellijPlatform {
@@ -222,27 +233,17 @@ tasks {
222233
)
223234
}
224235

225-
// withType<ClasspathIndexCleanupTask> {
226-
// onlyIf {
227-
// gradle.startParameter.taskNames.contains("test")
228-
// }
229-
// dependsOn(compileTestKotlin)
230-
// }
231-
232-
//
233-
// withType<ClasspathIndexCleanupTask> {
234-
// onlyIf {
235-
// gradle.startParameter.taskNames.contains("uiTest")
236-
// }
237-
// dependsOn("compileUiTestKotlin")
238-
// }
236+
withType<KotlinCompile>().configureEach {
237+
if (name == "compileUiTestKotlin") {
238+
onlyIf {
239+
gradle.startParameter.taskNames.any { it.contains("uiTests") }
240+
}
241+
}
242+
}
239243

240244
test {
241245
useJUnitPlatform()
242246

243-
// To run unit tests only and do not trigger "uiTest" task related things (like "compileUiTestKotlin")
244-
onlyIf { !gradle.startParameter.taskNames.contains("uiTest") }
245-
246247
testLogging {
247248
events("passed", "skipped", "failed")
248249
}
@@ -312,102 +313,101 @@ tasks {
312313
.map { it }
313314
)
314315
}
315-
316-
// TODO: fix
317-
// downloadRobotServerPlugin {
318-
// version.set(remoteRobotVersion)
319-
// }
320-
321-
// TODO: fix
322-
// runIdeForUiTests {
323-
// systemProperty("idea.trust.all.projects", "true")
324-
// systemProperty("ide.show.tips.on.startup.default.value", "false")
325-
// }
326316
}
327317

328318
/**
329-
* Adds uiTest source sets
319+
* UI tests task. Describes setup that provides the tools to run UI tests.
320+
* This task is available only for IDEs since version 242
330321
*/
331-
sourceSets {
332-
main {
333-
java {
334-
srcDir("src/${descriptor.sourceFolder}/kotlin")
335-
}
336-
resources {
337-
srcDir("src/${descriptor.sourceFolder}/resources")
322+
// https://github.com/JetBrains/intellij-community/blob/master/platform/remote-driver/README.md
323+
val uiTests by intellijPlatformTesting.testIdeUi.registering {
324+
task {
325+
enabled = gradle.startParameter.taskNames.any { it.contains("uiTests") } && descriptor.since >= "242"
326+
archiveFile.set(tasks.buildPlugin.flatMap { it.archiveFile })
327+
testClassesDirs = sourceSets["uiTest"].output.classesDirs
328+
classpath = sourceSets["uiTest"].runtimeClasspath
329+
330+
useJUnitPlatform {
331+
isScanForTestClasses = false
332+
includeTags("New")
338333
}
339-
}
340-
create("uiTest") {
341-
compileClasspath += sourceSets.main.get().output
342-
runtimeClasspath += sourceSets.main.get().output
343-
java.srcDirs("src/uiTest/java", "src/uiTest/kotlin")
344-
resources.srcDirs("src/uiTest/resources")
345-
}
346-
}
347334

348-
/**
349-
* configures the UI Tests to inherit the testImplementation in dependencies
350-
*/
351-
val uiTestImplementation by configurations.getting {
352-
extendsFrom(configurations.testImplementation.get())
353-
}
354-
355-
/**
356-
* configures the UI Tests to inherit the testRuntimeOnly in dependencies
357-
*/
358-
configurations["uiTestRuntimeOnly"].extendsFrom(configurations.testRuntimeOnly.get())
335+
jvmArgumentProviders += CommandLineArgumentProvider {
336+
listOf(
337+
"-Xmx2g",
338+
"-Xms512m",
339+
"-Dide.test.version=${descriptor.sdkVersion}",
340+
"-Dplugin.path=${tasks.buildPlugin.flatMap { it.archiveFile }.get().asFile.absolutePath}",
341+
"-Dui.tests.mock.project.path=src/uiTest/resources/mock_project",
342+
"-Didea.trust.all.projects=true",
343+
"-Dide.show.tips.on.startup.default.value=false",
344+
"-Didea.log.config.properties.file=src/uiTest/resources/log.properties",
345+
"-Didea.log.path=src/uiTest/resources/mock_project",
346+
// TODO: delete
347+
"-DideLaunchFolder=ide_for_launch",
348+
"-DremoteRobotUrl=http://127.0.0.1",
349+
"-DideaBuildVersionForTest=ideaIC-242.20224.91",
350+
"-DrobotServerForTest=robot-server-plugin-0.11.23",
351+
"-Didea.trust.all.projects=true",
352+
"-Dide.show.tips.on.startup.default.value=false",
353+
"-Dkotest.framework.classpath.scanning.autoscan.disable=true",
354+
)
355+
}
359356

360-
/**
361-
* runs UI tests
362-
*/
363-
val uiTest = task<Test>("uiTest") {
364-
description = "Runs the integration tests for UI."
365-
group = "verification"
366-
systemProperty("ideLaunchFolder", System.getProperty("ideLaunchFolder"))
367-
systemProperty("forMainframePath", System.getProperty("forMainframePath"))
368-
systemProperty("remoteRobotUrl", System.getProperty("remoteRobotUrl"))
369-
systemProperty("ideaVersionForTest", System.getProperty("ideaVersionForTest"))
370-
systemProperty("ideaBuildVersionForTest", System.getProperty("ideaBuildVersionForTest"))
371-
systemProperty("robotServerForTest", System.getProperty("robotServerForTest"))
372-
testClassesDirs = sourceSets["uiTest"].output.classesDirs
373-
classpath = sourceSets["uiTest"].runtimeClasspath
374-
useJUnitPlatform {
375-
excludeTags("FirstTime")
376-
excludeTags("SmokeTest")
377-
}
378-
testLogging {
379-
events("passed", "skipped", "failed")
357+
testLogging {
358+
events("passed", "skipped", "failed", "standardOut", "standardError")
359+
}
380360
}
381-
}
382361

383-
/**
384-
* Runs the first UI test, which agrees to the license agreement
385-
*/
386-
val firstTimeUiTest = task<Test>("firstTimeUiTest") {
387-
description = "Gets rid of license agreement, etc."
388-
group = "verification"
389-
testClassesDirs = sourceSets["uiTest"].output.classesDirs
390-
classpath = sourceSets["uiTest"].runtimeClasspath
391-
useJUnitPlatform {
392-
includeTags("FirstTime")
393-
}
394-
testLogging {
395-
events("passed", "skipped", "failed")
362+
plugins {
363+
robotServerPlugin()
396364
}
397-
}
398365

399-
/**
400-
* Runs the smoke ui test
401-
*/
402-
val smokeUiTest = task<Test>("smokeUiTest") {
403-
description = "Gets rid of license agreement, etc."
404-
group = "verification"
405-
testClassesDirs = sourceSets["uiTest"].output.classesDirs
406-
classpath = sourceSets["uiTest"].runtimeClasspath
407-
useJUnitPlatform {
408-
includeTags("SmokeTest")
409-
}
410-
testLogging {
411-
events("passed", "skipped", "failed")
366+
dependencies {
367+
// testImplementation(libs.junit.platform.launcher)
368+
// testImplementation(libs.junit.platform.suite)
369+
// testImplementation(libs.junit.jupiter)
370+
// testImplementation(libs.junit.jupiter.engine)
371+
testImplementation(libs.junit.jupiter.api)
372+
testImplementation(libs.junit.jupiter.params)
373+
testImplementation(libs.okhttp3.mockwebserver)
374+
testImplementation(libs.okhttp3.okhttp.tls)
375+
// TODO: revise and delete old unnecessary deps
376+
testImplementation("com.intellij.remoterobot:ide-launcher:0.11.23")
377+
testImplementation("com.intellij.remoterobot:remote-robot:0.11.23")
378+
testImplementation("com.intellij.remoterobot:remote-fixtures:0.11.23")
412379
}
413380
}
381+
382+
// TODO: fix
383+
///**
384+
// * Runs the first UI test, which agrees to the license agreement
385+
// */
386+
//val firstTimeUiTest = task<Test>("firstTimeUiTest") {
387+
// description = "Gets rid of license agreement, etc."
388+
// group = "verification"
389+
// testClassesDirs = sourceSets["uiTest"].output.classesDirs
390+
// classpath = sourceSets["uiTest"].runtimeClasspath
391+
// useJUnitPlatform {
392+
// includeTags("FirstTime")
393+
// }
394+
// testLogging {
395+
// events("passed", "skipped", "failed")
396+
// }
397+
//}
398+
//
399+
///**
400+
// * Runs the smoke ui test
401+
// */
402+
//val smokeUiTest = task<Test>("smokeUiTest") {
403+
// description = "Gets rid of license agreement, etc."
404+
// group = "verification"
405+
// testClassesDirs = sourceSets["uiTest"].output.classesDirs
406+
// classpath = sourceSets["uiTest"].runtimeClasspath
407+
// useJUnitPlatform {
408+
// includeTags("SmokeTest")
409+
// }
410+
// testLogging {
411+
// events("passed", "skipped", "failed")
412+
// }
413+
//}

0 commit comments

Comments
 (0)