Skip to content

Commit

Permalink
build: Move integration tests into separate test suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-todorov committed Oct 29, 2024
1 parent c7d9375 commit 54b0d03
Show file tree
Hide file tree
Showing 26 changed files with 49 additions and 27 deletions.
74 changes: 48 additions & 26 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,50 @@ java {
withJavadocJar()
}

// Configure multiple test sources
testing {
suites {
// Just for self reference, technically this is already configured by default.
val test by getting(JvmTestSuite::class) {
useJUnitJupiter() // already the default.
testType.set(TestSuiteType.UNIT_TEST) // already the default.
}

// testIntegration test sources
val testIntegration by registering(JvmTestSuite::class) {
val self = this
testType.set(TestSuiteType.INTEGRATION_TEST)

// We need to manually add the "main" sources to the classpath.
sourceSets {
named(self.name) {
compileClasspath += sourceSets.main.get().output + sourceSets.test.get().output
runtimeClasspath += sourceSets.main.get().output + sourceSets.test.get().output
}
}

// Inherit implementation, runtime and test dependencies (adds them to the compile classpath)
configurations.named("${self.name}Implementation") {
extendsFrom(configurations.testImplementation.get())
extendsFrom(configurations.runtimeOnly.get())
extendsFrom(configurations.implementation.get())
}

// Make sure the integration test is executed as part of the "check" task.
tasks.named<Task>("check") {
dependsOn(named<JvmTestSuite>(self.name))
}

tasks.named<Task>(self.name) {
mustRunAfter(test)
}

}
}


}

dependencies {
api(platform("software.amazon.awssdk:bom:2.16.28")) {
// Change the `AWS_VERSION` in ./docs/mkocs.yaml file.
Expand Down Expand Up @@ -142,6 +186,10 @@ tasks {
}
}

named<Task>("check") {
dependsOn(named<Task>("testIntegration"))
}

named<Task>("jacocoTestReport") {
group = "jacoco"
dependsOn(named("test")) // tests are required to run before generating the report
Expand All @@ -164,32 +212,10 @@ tasks {
group = "sonar"
}

named<Test>("test") {
description = "Run unit tests"
outputs.upToDateWhen { false }
useJUnitPlatform {
filter {
excludeTestsMatching("*IT")
}
}
}

withType<Test> {
defaultCharacterEncoding = "UTF-8"
}

create<Test>("it-s3") {
group = "verification"
description = "Run integration tests using S3"
useJUnitPlatform {
filter {
includeTestsMatching("*IT")
includeTags("it-s3")
}
}
mustRunAfter(named("test"))
}

// TODO: There are some problems with using minio that overcomplicate the setup.
// For the time being we'll be disabling it until we figure out the best path forward.
// create<Test>("it-minio") {
Expand All @@ -203,10 +229,6 @@ tasks {
// }
// }

named<Task>("check") {
dependsOn(named("it-s3"))
}

withType<Sign> {
onlyIf {
(project.hasProperty("withSignature") && project.findProperty("withSignature") == "true") ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class S3ClientIT extends BaseIntegrationTest
public void setup()
{
// s3client
final Map<String, Object> credentials = getRealEnv();
final Map<String, Object> credentials = EnvironmentBuilder.getRealEnv();

final AwsCredentials credentialsS3 = AwsBasicCredentials.create(credentials.get(ACCESS_KEY).toString(),
credentials.get(SECRET_KEY).toString());
Expand Down

0 comments on commit 54b0d03

Please sign in to comment.