This one has been bugging me for quite some time and I felt like I should report it.
If one module, in a multi-module project, does not have any unit tests, for some reason, scanning fails.
There are numerous cases when it can happen that a module does not have any unit tests, for example if sources in the module is used by test code only. Or if tests at the moment do not exist (SonarQube could then warn about low code coverage, there are rules for that).
The current workaround is to create a dummy file in âsrc/testâ so that the folder exists⌠But no tests is are actually needed.
My suggestion is to fix this and convert this build error into a warning instead.
The folder âsrc/testâ does not exist for â:domainTestStubsâ (base directory = /Users/buildagent/builds/zxtdf38xr/0/x/y/apps/myproject/core/domain-test-stubs)
I did this before, as I was told it was no longer necessary to specify sonar.sources/sonar.tests but then I ran into problems (I donât remember the details, but either code was missing from the analysis or test coverage got skewed) so I had to revert to explicitly set these properties.
Ah, I missed something. I thought for a moment that the issue was sonar.sources containing a reference to your test folder. That wouldnât make sense, since tests should be passed to sonar.tests.
So I wonder if for Java projects it makes sure the directory exists⌠but not for Android projects. While we have an integration test for java projects with no tests, I donât see one for Android.
Iâm going to flag this for some expert eyes. Sorry for the confusion earlier.
I have a few questions: does the folder src/test exist? If no, then you have to explicitly specify sonar.tests to be an empty String and that should fix your problem.
Another question do you want to analyze that module at all or it can be skipped?
Weâll see what we can do here, but most likely itâs better to explicitly mention that you donât have test files.
You donât need to specify sonar.sources and sonar.tests in the default case, but your situation is not default, so itâs valid to specify sonar.tests to be an empty string.
Hi,
no, the folder does not exist (not possible to check in empty folders in git).
Thanks for the workaround, but it doesnât really address the real issue in my opinion.
I think the analysis should handle that you specify a directory that doesnât exist that could result in a warning instead of failing the analysis
Thanks for your concern. Weâll discuss within the team. while youâre right. There are also cases when the absence of sonar.tests is indeed a bug a misconfiguration, so it would be nice to notice this faster the have an incorrect analysis result.