Spock tests are not recognized

In SonarQube 9.9 Spock tests are not recognized.

At the point where the graph ends, the JUnit 4 tests were replaced by Spock tests:

It would be nice if SonarQube would also recognize Spock tests.

Hey there.

SonarQube will recognize any kind of tests, as long as it receives a report with the test results in the right format. For Java, that’s JUnit Surefire reports (Test execution parameters) or generic test execution reports (Generic test data).

Hm, right I forgot that, but I set the sonar.junit.reportPaths properties for the modules to the directories where the "TEST{,S}-*.xml` files are present for the modules where Test were run.

Any way to see why the tests are not recognized?

The log also shows for the two modules with tests

[:sonar] Sensor SurefireSensor [java]
[:sonar]   apply
[:sonar] parsing [/var/lib/teamcity-buildAgent/work/aed74103c764f0f2/mobile-sl/build/test-results/test]
[:sonar] Sensor SurefireSensor [java] (done) | time=16ms

with the correct path to the XMLs and for the other two modules some default path as the property is not configured for those.

I debugged into the SurefireSensor execution, and the XML files are actually parsed properly.
But then when the SurefireJavaParser tries to mapToInputFile, it doesn’t find any files, as the Test files are Groovy files with Spock, not Java files.

I also checked, sonar.tests for those modules is set to the respective Groovy test source directories that contain the test files.

You might be able to fix that by installing a community-supported plugin that will index Groovy files (GitHub - Inform-Software/sonar-groovy: SonarQube plugin for Groovy).