How to start apps and run tests in multiproject build

I have a multi-project build.

It contains four sample apps.

I would like to have one gradle task that will:

  1. start sample app 1:
    ./gradlew :simple:app1:run
  2. once app 1 is started, execute tests against the running sample app 1:
    ./gradlew :simple:loadtests-app1:gatlingRun
  3. shut down sample app 1
  4. start sample app 2
  5. once app 2 is started, execute tests against the running sample app 2
    etc.

Any advice on how best to accomplish this?

Thanks!

I don’t think Gradle provides out of the box support for all of the steps you want. For the shut down sample app 1 step for example, I assume you would probably need to have the process ID of your running app 1. I don’t think there’s anything in the Gradle API that gives you that.

You might be able to put together a roll your own solution using java.lang.Process though. Possibly that together with TestKit might get you something close to what you’re after.

And, of course, there might be some non-obvious built in Gradle features that do exactly what you want which somebody else in the forum could suggest.

So scour through the docs, see what you can find and please come back and let everybody know whatever solution you eventually figure out?