How can I run a test inside each subproject?

You could do similar to this where you copy a test case into each subproject under $buildDir/generated then add the generated directory as a test source directory in each subproject