This message was deleted.
# community-support
s
This message was deleted.
g
If you have Download task and a Test task and what you want is to have Download always run before Test automatically, you can declare that
test.dependsOn(download)
(https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:adding_dependencies_to_tasks)
g
will it work also if I run from the gui the whole class test or the single test method?
g
That depends on how that GUI runs the tests. If you mean an IntelliJ IDE, like Android Studio or IDEA, it should work because it runs tests using Gradle.
g
ok, so if the cli for the test is
:cleanJvmTest :jvmTest --tests "io.scif.formats.apng.ApngTest"
, then how can I define the corresponding test task?
g
If you're in a Kotlin project, the Test-type task is already defined (in other cases too, but
jvmTest
sounds like Kotlin Multiplatform). You don't need to create a Test task, just your Download task, then set the existing test task to depend on Download. You could do something like this
Copy code
tasks.named("jvmTest") {
  dependsOn(tasks.named("downloadTaskName"))
}
g
yeah, it's KMP. I'd need to create a dependency on the specific
ApngTest
, is it possible?
g
Not in the default setup, I think. I see two options: 1. The most idiomatic: move
ApngTest
to a new test suite. Declare a new suite (see docs), then set the testTask of that suite to depend on download
Copy code
register<JvmTestSuite>("pngTest") { 
            targets { 
                all {
                    testTask.configure {
                        dependsOn(tasks.named("downloadTaskName"))
                    }
                }
            }
        }
2. The easiest: you keep requesting both tasks when you run, i.e.
:downloadTaskName :jvmTest --tests "io.scif.formats.apng.ApngTest"
, but you can specify that jvmTest needs to wait for the download task (if the download task was requested)
Copy code
tasks.named("jvmTest") {
  mustRunAfter(tasks.named("downloadTaskName"))
}
g
the "test suite" approach looks interesting, thanks for pointing that out, Gabriel 🙂
🙂 1