Some test exclusions are not working

  • ALM used - GitHub
  • CI system used - GitHub actions
  • Scanner command used when applicable - N/A
  • Languages of the repository - typescript
  • Only if the SonarCloud project is public, the URL - N/A
    • And if you need help with pull request decoration, then the URL to the PR too - N/A
  • Error observed - N/A
  • Steps to reproduce

sonar.exclusions=**/*.js <<< this works
sonar.test.exclusions=**/test/**/*.test.ts,**/test/**/*.spec.ts,**/test/**/*.test.tsx,**/test/**/*.spec.tsx <<< this does not work

  • Potential workaround - N/A

can someone help me please? anything wrong with the test exclusion rule here?

Thanks.

Hi @Gihan_Wijerathne

which scanner are you using and what is your complete set of settings?
eg How do you set sonar.sources and sonar.tests? And if you do not explicitly set them, you should check in Background Tasks / Scanner Context how they are set.

Regards,
Wiebke

Thanks Wiebke Schwierz.

I’m using sonarcloud.
I think I understood the mistake from your comment. I have not set sonar.tests.
Can you confirm that sonar.test.exclusions is not effective without sonar.tests?

Hi Gihan,

yes that might be the problem. I think it depends on the scanner you are using. Using sonarcloud is not related to the scanner you are using.

According to the documentation, if you use the scanners for maven, gradle or .net there the default for this parameter is taken from your project configuration (e.g. pom file entries in maven). Otherwise sonar.tests is not set if you don’t set it explicitly.
You can see which values are effectively used for the parameters if you look into the scanner context like described above.

If sonar.tests is not set and your test sources are scanned as source code then your setting of sonar.test.exclusions will probably have no effect.

Regards, Wiebke

Thanks Wiebke.

Appreciate your response.

Cheers!

1 Like