From ac1f9aa1cc39ef5384282f59a6452efb101b04a0 Mon Sep 17 00:00:00 2001 From: Rick Choi Date: Mon, 20 Jan 2025 16:07:04 +0000 Subject: [PATCH] [ESWE-1181] Refactor tests (#11) - split tests into `test` (unit tests) and `integrationTest` (integration tests) - extract `integrationTest` (via of `jvm-test-suite` plugin) --- build.gradle.kts | 40 ++++++++++++++++--- .../integration/ExampleResourceIntTest.kt | 0 .../integration/IntegrationTestBase.kt | 0 .../integration/NotFoundTest.kt | 0 .../integration/OpenApiDocsTest.kt | 0 .../integration/ResourceSecurityTest.kt | 0 .../integration/health/HealthCheckTest.kt | 0 .../integration/health/InfoTest.kt | 0 .../wiremock/ExampleApiMockServer.kt | 0 .../wiremock/HmppsAuthMockServer.kt | 0 .../resources/application-test.yml | 0 11 files changed, 34 insertions(+), 6 deletions(-) rename src/{test => integrationTest}/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/ExampleResourceIntTest.kt (100%) rename src/{test => integrationTest}/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/IntegrationTestBase.kt (100%) rename src/{test => integrationTest}/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/NotFoundTest.kt (100%) rename src/{test => integrationTest}/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/OpenApiDocsTest.kt (100%) rename src/{test => integrationTest}/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/ResourceSecurityTest.kt (100%) rename src/{test => integrationTest}/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/health/HealthCheckTest.kt (100%) rename src/{test => integrationTest}/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/health/InfoTest.kt (100%) rename src/{test => integrationTest}/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/wiremock/ExampleApiMockServer.kt (100%) rename src/{test => integrationTest}/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/wiremock/HmppsAuthMockServer.kt (100%) rename src/{test => integrationTest}/resources/application-test.yml (100%) diff --git a/build.gradle.kts b/build.gradle.kts index 66fbe75..c893384 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ plugins { id("uk.gov.justice.hmpps.gradle-spring-boot") version "6.1.2" kotlin("plugin.spring") version "2.0.21" + `jvm-test-suite` } configurations { @@ -14,20 +15,47 @@ dependencies { implementation("uk.gov.justice.service.hmpps:hmpps-sqs-spring-boot-starter:5.2.2") implementation("org.springframework.boot:spring-boot-starter-webflux") implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.7.0") - - testImplementation("uk.gov.justice.service.hmpps:hmpps-kotlin-spring-boot-starter-test:1.1.1") - testImplementation("org.wiremock:wiremock-standalone:3.9.2") - testImplementation("io.swagger.parser.v3:swagger-parser:2.1.24") { - exclude(group = "io.swagger.core.v3") - } } kotlin { jvmToolchain(21) } +testing { + suites { + @Suppress("UnstableApiUsage") + val test by getting(JvmTestSuite::class) { + useJUnitJupiter() + } + + @Suppress("UnstableApiUsage") + register("integrationTest") { + dependencies { + kotlin.target.compilations { named("integrationTest") { associateWith(getByName("main")) } } + implementation("uk.gov.justice.service.hmpps:hmpps-kotlin-spring-boot-starter-test:1.1.1") + implementation("org.wiremock:wiremock-standalone:3.9.2") + implementation("io.swagger.parser.v3:swagger-parser:2.1.24") { + exclude(group = "io.swagger.core.v3") + } + } + + targets { + all { + testTask.configure { + shouldRunAfter(test) + } + } + } + } + } +} + tasks { withType { compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21 } + + check { + dependsOn(named("test"), named("integrationTest")) + } } diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/ExampleResourceIntTest.kt b/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/ExampleResourceIntTest.kt similarity index 100% rename from src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/ExampleResourceIntTest.kt rename to src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/ExampleResourceIntTest.kt diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/IntegrationTestBase.kt b/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/IntegrationTestBase.kt similarity index 100% rename from src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/IntegrationTestBase.kt rename to src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/IntegrationTestBase.kt diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/NotFoundTest.kt b/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/NotFoundTest.kt similarity index 100% rename from src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/NotFoundTest.kt rename to src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/NotFoundTest.kt diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/OpenApiDocsTest.kt b/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/OpenApiDocsTest.kt similarity index 100% rename from src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/OpenApiDocsTest.kt rename to src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/OpenApiDocsTest.kt diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/ResourceSecurityTest.kt b/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/ResourceSecurityTest.kt similarity index 100% rename from src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/ResourceSecurityTest.kt rename to src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/ResourceSecurityTest.kt diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/health/HealthCheckTest.kt b/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/health/HealthCheckTest.kt similarity index 100% rename from src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/health/HealthCheckTest.kt rename to src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/health/HealthCheckTest.kt diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/health/InfoTest.kt b/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/health/InfoTest.kt similarity index 100% rename from src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/health/InfoTest.kt rename to src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/health/InfoTest.kt diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/wiremock/ExampleApiMockServer.kt b/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/wiremock/ExampleApiMockServer.kt similarity index 100% rename from src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/wiremock/ExampleApiMockServer.kt rename to src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/wiremock/ExampleApiMockServer.kt diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/wiremock/HmppsAuthMockServer.kt b/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/wiremock/HmppsAuthMockServer.kt similarity index 100% rename from src/test/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/wiremock/HmppsAuthMockServer.kt rename to src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/jobsboardintegrationapi/integration/wiremock/HmppsAuthMockServer.kt diff --git a/src/test/resources/application-test.yml b/src/integrationTest/resources/application-test.yml similarity index 100% rename from src/test/resources/application-test.yml rename to src/integrationTest/resources/application-test.yml