Note: The build I’m working on is a multi-project build. This may impact what solutions will work.
I have a project with “unit tests” that are in pretty bad shape. Running all of them for the entire project takes far too long on a developer laptop. We want them to run on Jenkins or if the user explicitly runs gradle test or gradle clean test or something like that.
How can I modify my build so that tests are run when explicitly requested and skipped when they aren’t requested? I don’t want every developer to have to specify -x test every time they run the tests, especially because this is a multi-project build and some of the projects have unit tests that I’d like to run every time (because they’re actually decent unit tests).
Things I’ve tried:
- check.dependsOn.remote(test) which works perfectly (but is deprecated and will be removed).
- test.enabled = false which doesn’t work (it doesn’t run the tests when they’re explicitly requested, i.e., it behaves as expected but not as desired).
A thought I’ve had: Is there some way to check the command-line arguments to see if test was explicitly requested as a task and disable it if it wasn’t explicitly requested?