Gradle runner and --tests filter

We’d like to set up a build configuration that uses the Gradle runner but only runs a subset of tests via Test Filtering. Unfortunately, it seems impossible to do this using the `--tests` command-line option. The root of the issue seems to be that “Additional Gradle command line parameters” are inserted before the task names, but `--tests` must come after the test task name.

Unless there’s another workaround, or something we’re missing, we’ll be implementing some logic that uses a property, set via `-P`, that configures the filter as below:

test {
    filter {
        includeTestsMatching testFilterPattern // set via -PtestFilterPattern='examplePattern*'
}
}
2 comments

Hi Christian,

 

a possibility for your scenario could be to simply specify in the gradle tasks field the "--tests" parameter instead of the additional command line parameters. If you need to set it via a custom build, you can put it as a reference to an empty parameter which then is forced in the custom build dialog.

 

The field is passed directly into a command line, so, while I haven't tested it explicitly, it should work. Could you give it a try?

0

Hi Denis,

Thanks for the reply!

I did eventually get this working via the `tasks` field, with one catch: I initially was quoting the pattern (`--tests '*.A*'`) to avoid any issues with shell expansion. However, it seems the quotes were getting passed through verbatim to Gradle, so I got errors like No tests found for given includes: ['*.A*']. When I removed them (`--tests *.A*`), it worked.

 

0

Please sign in to leave a comment.