Running test via context ignores task dependsOn from Gradle

已回答

For our integration tests, we have a dependency configured in Gradle, to run specific tests that verify the database being tested against is up-to-date:

tasks.register<Test>("integrationTest") {
group = "Verification"
description = "Runs the tests with IntegrationTest tag."
useJUnitPlatform {
excludeTags("ManualTest")
includeTags("IntegrationTest")
}

// Verify the database is up-to-date before executing the integration tests.
dependsOn(":<module>:verifyDatabaseIsUpToDate")
}

And in the different module:

tasks.register<Test>("verifyDatabaseIsUpToDate") {
group = "Verification"
description = "Verifies that the database being tested against is up to date (having executed all expected scripts)."

useJUnitPlatform()
filter {
includeTest("<qualified-testclass>", null)
}

// always run database tests
outputs.cacheIf { false }
outputs.upToDateWhen{ false }
}

This works if I run all our integration tests via gradle (via the gradle tab or command) or if I run a specific test via the gradle command window (gradle integrationTest --tests "<qualified-integration-test-class>"), but if I run a test via the context menu, the dependency is executed but the result is ignored and the test is still executed even if the dependency failed.

0

>but if I run a test via the context menu, the dependency is executed but the result is ignored and the test is still executed even if the dependency failed.

What Run/Debug Configuration is created for this case?

Can you show the output when you run it in terminal and when it is run from the IDE via the test file context menu?

0

请先登录再写评论。