Running tests without building/compiling

I have a multi-project build with a structure of the form (purely-representational)

root

  • java_common
  • object_layer
    • model
    • object_data
  • impression
  • storage

For each of the projects, I have two kinds of tasks defined -> unitTests and integrationTests both of the type Test. I am trying to figure out the best way to reduce the amount of time taken to run these two tasks for all the projects in the system. The only constraint is that if the integration tests are run in parallel, each parallel jvm needs to be provided a specific environment variable (think of this as a backend that the integration test will use) and it needs to be different for each parallel worker.

Given these constraints, I would like to understand if

  1. Is there a way to run gradle test tasks without any compilation/build steps. An assumption I can make is that gradle build -x test is always run prior to running tests.
  2. Is there a way to pass different arguments to different projects when running them in parallel? Have tried to read up on the WorkerAPI to see if it can be used to achieve this but it does not seem likely.

I think what you are looking for is the build cache, which is built for avoiding executing of building/compiling. We have a section on how to deal with integration tests in the build cache guide.

Cheers,
Stefan