(what Im trying to do is run only certain tests vi...
# gradle
u
(what Im trying to do is run only certain tests via that task)
g
You need custom test task for this <https//docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html|https//docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html> So in your task instead of depending on particular task and pass arguments, create own version of this task
u
I'm not sure if I follow. That
test { }
block looks like a configuration for every / or the default test task, no?
how do they get the
gradlew someTestTask
at the end from it?
same thing here, the filtering https://docs.gradle.org/current/userguide/java_testing.html, it looks like it customizes what
gradlew test
runs afaik
g
There is no test block, there is a task with name "test" and type org.gradle.api.tasks.testing.Test, it has own config, you can change it, but you shouldn't do this from another task, even if it's possible, it's against best practices and very fragile itself
If you need a custom test runner, just create own instance of test task with required config
u
oh so that from your example translates to
Copy code
task test(type: Test) {
 
}
?
i.e. I can rename it to
Copy code
myWhateverTest {
   ..
}
?
I thought it was configuration for
gradlew test
so In my top level build.gradle I added
Copy code
task myTest(type: Test) {
    group = "verification"

    include "com.myapp.foo.MessageManagerTest.class"
}
FAILURE: Build failed with an exception. * What went wrong: Could not determine the dependencies of task ':myTest'.
java.lang.NullPointerException (no error message)
omg I think Im starting to figure out gradle .. the thing that looks like a function parameter, that is inheritance/delegation?????
g
Yes, it's syntax for task creation/configuration and Test is type of new task
u
any clue on as how to actually implement the custom task please? its still bitching about unknown dependencies of the task as above, I googled it should depends on
testClasses
but ofcourse such task doesnt exist in my
graldew tasks
. gradle is the worst, random attempts, sync run & pray