I’m trying to run tests as gradle tasks from IntelliJ with specifying which tests do I actually want to run.

From the console the tests run fine:
./gradlew myTestTask --tests 'com.mycompany.MyTestClass'

But if I create a new run/debug configuration in IntelliJ with myTestTask as the task and --tests 'com.mycompany.MyTestClass' as the script parameters then the runs produce errors like:

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':myProject:myTestTask'.
> No tests found for given includes: ['com.mycompany.MyTestClass']

Apparently IntelliJ puts singe quotes around the task + script parameters, as it can be seen from the third line of the output and this seems to cause problems

1:16:34 PM: Executing external task 'myTestTask --tests 'com.mycompany.MyTestClass''...

Using double quotes instead of single ones solves the problem, and the configuration runs fine:
--tests "com.mycompany.MyTestClass"

Leave a Reply

Your email address will not be published. Required fields are marked *