[Sonar Cloud] How to run aggregate multiple test results in GH Actions using Gradle Java JUnit5

Tech used:

  • Github
  • Github Actions
  • gradle sonar
  • Java

Hello,
currently we have a GH actions workflow that executes for every PR a big bunch of JUnit5 tests using Gradle and then runs Sonar Analysis using Gradle´s plugin.
This works, but the problem is that there are different types of tests (some of them are slow, others use native libs, etc) so we would like to split those tests and run them using different suites in parallel (3 suites in total).
So, I’d like to explore what are the different options here:

  1. Run tests in parallel and, when all of them finish, run a job that collects all jacoco exec files from the previous executions and then run the Sonar Analysis
  2. Every test execution runs Sonar too (3 Sonar analysis)
  3. Any other option?

I think ideally #1 would be better so that we only run Sonar once but I don’t know if this would feasible.
For option #2, It would be easier setup, but I’m worried about last analysis overriding coverage results from previous analysis
Could you let me know if both approaches are feasible? Any other idea?

Thanks in advance

Hey there.

I agree that you really don’t want to run Sonar on every test execution (#2), as each run would overwrite the previous results.

It looks like some other users have worked on accomplishing #1:

Maybe one of their solutions is helpful for you?

Hi Colin,
thanks for your response.
We don’t have multiple modules nor suites configured.
I finally made it by uploading all .exec files generated by jacoco plugin during tests to a job that downloads all of them and executes jacocoTestReport task (to generate xml files needed by sonar) and finally call sonar analysis task

kind regards

1 Like