Skip to content

Commit

Permalink
added lazy configuration of test tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
tarasgor-allegro committed Nov 20, 2024
1 parent 1b7f646 commit 74cd56d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ktlint {
version = "1.4.0"
}

tasks.withType<Test> {
tasks.withType<Test>().configureEach {
useJUnitPlatform()
testLogging {
events("passed", "failed", "skipped")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ package com.coditory.gradle.integration
import com.coditory.gradle.integration.IntegrationTestPlugin.Companion.INTEGRATION_TEST
import com.coditory.gradle.integration.IntegrationTestPlugin.Companion.TEST_ALL_TASK_NAME
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.tasks.testing.Test
import org.gradle.language.base.plugins.LifecycleBasePlugin

internal object TestAllTaskConfiguration {
fun apply(project: Project, config: IntegrationTestPluginConfig) {
val testAllTask = project.tasks.create(TEST_ALL_TASK_NAME)
testAllTask.description = "Runs all test suites."
testAllTask.group = LifecycleBasePlugin.VERIFICATION_GROUP
testAllTask.enabled = config.allTestTaskEnabled
project.tasks.withType(Test::class.java).forEach {
testAllTask.dependsOn(it.name)
project.tasks.register(TEST_ALL_TASK_NAME) { testAllTask: Task ->
testAllTask.description = "Runs all test suites."
testAllTask.group = LifecycleBasePlugin.VERIFICATION_GROUP
testAllTask.enabled = config.allTestTaskEnabled
project.tasks.withType(Test::class.java).forEach {
testAllTask.dependsOn(it.name)
}
testAllTask.dependsOn(INTEGRATION_TEST)
}
testAllTask.dependsOn(INTEGRATION_TEST)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ internal object TestSuitesConfiguration {
}

private fun setupTestTask(project: Project, config: IntegrationTestPluginConfig) {
val integrationTestTask = project.tasks.create(INTEGRATION_TEST)
integrationTestTask.description = "Runs integration test suites."
integrationTestTask.group = LifecycleBasePlugin.VERIFICATION_GROUP
integrationTestTask.enabled = config.integrationTestsEnabled
integrationTestTask.dependsOn(INTEGRATION)
project.tasks.register(INTEGRATION_TEST) { integrationTestTask ->
integrationTestTask.description = "Runs integration test suites."
integrationTestTask.group = LifecycleBasePlugin.VERIFICATION_GROUP
integrationTestTask.enabled = config.integrationTestsEnabled
integrationTestTask.dependsOn(INTEGRATION)
}
project.tasks.getByName(JavaBasePlugin.CHECK_TASK_NAME)
.dependsOn(INTEGRATION_TEST)
project.tasks.getByName(JavaBasePlugin.CHECK_TASK_NAME)
Expand Down

0 comments on commit 74cd56d

Please sign in to comment.