The Maven scanner should indeed correctly set these properties correctly by default and you should not have to do it by yourself.
Can I ask you to verify your analysis parameters (or analysis context), or share them, anonymized, and double-check that (even if it might sound completely obvious):
- The file is correctly placed in a test folder, included in what property
sonar.tests
defines - There is no override of the property
sonar.sources.inclusions
which might include test folders?
Cheers,
Michael