From 3c0962d55903ba7054e68d582d1f732ad28a88fd Mon Sep 17 00:00:00 2001 From: Swordsteel Date: Fri, 1 Nov 2024 12:07:29 +0000 Subject: [PATCH] add plugin service integration test --- README.md | 10 +++++ ...plugin.service-integration-test.gradle.kts | 38 +++++++++++++++++++ ...in.hlaeja-common-plugin.service.gradle.kts | 1 + 3 files changed, 49 insertions(+) create mode 100644 src/main/kotlin/ltd.hlaeja.plugin.hlaeja-common-plugin.service-integration-test.gradle.kts diff --git a/README.md b/README.md index 829ebf8..d698300 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,16 @@ container and docker ports can be a single port (e.g., 8080) or multiple ports s * `containerNetworkCreate` creates network. * `containerNetworkRemove` removes network. +### Plugin Service Integration Test + +id `ltd.hlaeja.plugin.hlaeja-common-plugin.service-integration-test` + +Adding task `integrationTest` to run integration test, add to `verification` group and add to task `check`. + +Adding intellij support `src/integration-test/java`, `src/integration-test/kotlin`, and `src/integration-test/resources` as test module in intellij. + +Adding dependencies support `integrationTestImplementation()`, and `integrationTestRuntimeOnly()` as part of Gradle. + ## Releasing plugin Run `release.sh` script from `master` branch. diff --git a/src/main/kotlin/ltd.hlaeja.plugin.hlaeja-common-plugin.service-integration-test.gradle.kts b/src/main/kotlin/ltd.hlaeja.plugin.hlaeja-common-plugin.service-integration-test.gradle.kts new file mode 100644 index 0000000..921176a --- /dev/null +++ b/src/main/kotlin/ltd.hlaeja.plugin.hlaeja-common-plugin.service-integration-test.gradle.kts @@ -0,0 +1,38 @@ +plugins { + id("idea") + + kotlin("jvm") +} + +@Suppress("unused") +fun DependencyHandler.integrationTestImplementation( + dependencyNotation: Any, +): Dependency? = add("integrationTestImplementation", dependencyNotation) + +@Suppress("unused") +fun DependencyHandler.integrationTestRuntimeOnly( + dependencyNotation: Any, +): Dependency? = add("integrationTestRuntimeOnly", dependencyNotation) + +sourceSets.create("integration-test") { + compileClasspath += sourceSets["main"].output + runtimeClasspath += sourceSets["main"].output + idea.module { + testSources.from(sourceSets["integration-test"].kotlin.srcDirs, sourceSets["integration-test"].java.srcDirs) + testResources.from(sourceSets["integration-test"].resources.srcDirs) + } + configurations.let { + it["integrationTestImplementation"].extendsFrom(configurations.implementation.get()) + it["integrationTestRuntimeOnly"].extendsFrom(configurations.runtimeOnly.get()) + } +} + +tasks { + register("integrationTest") { + description = "Runs integration tests." + group = "verification" + testClassesDirs = sourceSets["integration-test"].output.classesDirs + classpath = sourceSets["integration-test"].runtimeClasspath + } + check { dependsOn(getByName("integrationTest")) } +} diff --git a/src/main/kotlin/ltd.hlaeja.plugin.hlaeja-common-plugin.service.gradle.kts b/src/main/kotlin/ltd.hlaeja.plugin.hlaeja-common-plugin.service.gradle.kts index fcdf328..f272be5 100644 --- a/src/main/kotlin/ltd.hlaeja.plugin.hlaeja-common-plugin.service.gradle.kts +++ b/src/main/kotlin/ltd.hlaeja.plugin.hlaeja-common-plugin.service.gradle.kts @@ -1,4 +1,5 @@ plugins { id("ltd.hlaeja.plugin.hlaeja-common-plugin.common") id("ltd.hlaeja.plugin.hlaeja-common-plugin.service-container") + id("ltd.hlaeja.plugin.hlaeja-common-plugin.service-integration-test") }