|
| 1 | +/* |
| 2 | + * SonarSource Cloud Native Gradle Modules |
| 3 | + * Copyright (C) 2024-2024 SonarSource SA |
| 4 | + * mailto:info AT sonarsource DOT com |
| 5 | + * |
| 6 | + * This program is free software; you can redistribute it and/or |
| 7 | + * modify it under the terms of the Sonar Source-Available License Version 1, as published by SonarSource SA. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 12 | + * See the Sonar Source-Available License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the Sonar Source-Available License |
| 15 | + * along with this program; if not, see https://sonarsource.com/license/ssal/ |
| 16 | + */ |
| 17 | +import org.gradle.api.tasks.testing.logging.TestExceptionFormat |
| 18 | +import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED |
| 19 | +import org.gradle.api.tasks.testing.logging.TestLogEvent.PASSED |
| 20 | +import org.gradle.api.tasks.testing.logging.TestLogEvent.SKIPPED |
| 21 | +import org.gradle.api.tasks.testing.logging.TestLogEvent.STARTED |
| 22 | +import org.sonarsource.cloudnative.gradle.IntegrationTestExtension |
| 23 | + |
| 24 | +// Inspiration: https://docs.gradle.org/current/samples/sample_jvm_multi_project_with_additional_test_types.html |
| 25 | + |
| 26 | +plugins { |
| 27 | + java |
| 28 | + id("org.sonarsource.cloud-native.java-conventions") |
| 29 | +} |
| 30 | + |
| 31 | +val integrationTest by sourceSets.creating |
| 32 | +val integrationTestConfiguration = extensions.create<IntegrationTestExtension>("integrationTest") |
| 33 | + |
| 34 | +configurations[integrationTest.implementationConfigurationName].extendsFrom(configurations.testImplementation.get()) |
| 35 | +configurations[integrationTest.runtimeOnlyConfigurationName].extendsFrom(configurations.testRuntimeOnly.get()) |
| 36 | + |
| 37 | +tasks.register<Test>("integrationTest") { |
| 38 | + description = "Runs integration tests." |
| 39 | + group = "verification" |
| 40 | + inputs.dir(integrationTestConfiguration.testSources) |
| 41 | + inputs.property("SQ version", System.getProperty("sonar.runtimeVersion", "LATEST_RELEASE")) |
| 42 | + inputs.property("keep SQ running", System.getProperty("keepSonarqubeRunning", "false")) |
| 43 | + useJUnitPlatform() |
| 44 | + |
| 45 | + testClassesDirs = integrationTest.output.classesDirs |
| 46 | + classpath = configurations[integrationTest.runtimeClasspathConfigurationName] + integrationTest.output |
| 47 | + |
| 48 | + if (System.getProperty("sonar.runtimeVersion") != null) { |
| 49 | + systemProperty("sonar.runtimeVersion", System.getProperty("sonar.runtimeVersion", "LATEST_RELEASE")) |
| 50 | + } |
| 51 | + |
| 52 | + if (System.getProperty("keepSonarqubeRunning") != null) { |
| 53 | + systemProperty("keepSonarqubeRunning", System.getProperty("keepSonarqubeRunning")) |
| 54 | + } |
| 55 | + |
| 56 | + testLogging { |
| 57 | + // log the full stack trace (default is the 1st line of the stack trace) |
| 58 | + exceptionFormat = TestExceptionFormat.FULL |
| 59 | + events(STARTED, PASSED, SKIPPED, FAILED) |
| 60 | + } |
| 61 | +} |
0 commit comments