|
| 1 | +tasks.register('apiTest', Test) { |
| 2 | + description = "Runs api tests against docker-compose stack" |
| 3 | + group = "Verification" |
| 4 | + |
| 5 | + mustRunAfter tasks.named('test') |
| 6 | + |
| 7 | + testClassesDirs = sourceSets.apiTest.output.classesDirs |
| 8 | + classpath = sourceSets.apiTest.runtimeClasspath |
| 9 | + useJUnitPlatform() |
| 10 | + |
| 11 | + dependsOn tasks.composeUp |
| 12 | + finalizedBy tasks.composeDown |
| 13 | + |
| 14 | + jvmArgs = ['-Xshare:off'] |
| 15 | + testLogging { |
| 16 | + events "passed", "skipped", "failed" |
| 17 | + exceptionFormat = 'full' |
| 18 | + showStandardStreams = true |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +tasks.named('check') { |
| 23 | + dependsOn tasks.named('apiTest') |
| 24 | +} |
| 25 | + |
| 26 | +tasks.named('build') { |
| 27 | + dependsOn tasks.named('test') |
| 28 | + dependsOn tasks.named('apiTest') |
| 29 | +} |
| 30 | + |
| 31 | +sourceSets { |
| 32 | + apiTest { |
| 33 | + java { |
| 34 | + compileClasspath += sourceSets.main.output |
| 35 | + runtimeClasspath += sourceSets.main.output |
| 36 | + |
| 37 | + } |
| 38 | + resources.srcDir file('src/apiTest/resources') |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +configurations { |
| 43 | + apiTestImplementation.extendsFrom testImplementation |
| 44 | + apiTestRuntimeOnly.extendsFrom testRuntimeOnly |
| 45 | + |
| 46 | + // Ensure testRuntimeClasspath can be resolved for agent injection |
| 47 | + testRuntimeClasspath { |
| 48 | + canBeResolved = true |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +dependencies { |
| 53 | + apiTestImplementation platform('org.junit:junit-bom:5.13.4') |
| 54 | + apiTestRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' |
| 55 | + |
| 56 | + apiTestImplementation('org.springframework.boot:spring-boot-starter-test') { |
| 57 | + exclude group: 'junit', module: 'junit' |
| 58 | + exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' |
| 59 | + } |
| 60 | + apiTestRuntimeOnly 'org.junit.platform:junit-platform-launcher' |
| 61 | + apiTestCompileOnly group: 'org.projectlombok', name: 'lombok', version: lombokVersion |
| 62 | + apiTestAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: lombokVersion |
| 63 | +} |
0 commit comments