At the moment, I’m trying to upload a .xml report of a unit test, using sonar.“testExecutionReportPaths”. The .xml is a modified xml created during bazel test, to have the same format as the one supported.
But it keeps giving me the error: “Caused by: java.lang.IllegalStateException: Line 2 of report refers to a file which is not configured as a test file:…”
I can’t realize why, as I follow the settings that are in the documentation.
As anyone found a similiar issue and, I hope, solution?
I just removed the sonar.test.inclusions and added the path of the test file directly in the sonar.tests. The error is different, it’s “can’t be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files”.
I did try to
But it still gives me “Line 2 of report refers to a file which is not configured as a test file:”
I can’t, however, isolate as you saied. Because my “sonar.sources” is the entire project and there’s several subprojects with tests folders. That’s the reason I have the “sonar.sources” to the project and the “sonar.tests” to the test that I want to upload a report.
you can specify multiple comma-separated dirs with sources and tests.
Also, you can keep it simple with something like that
# Define same root directory for main sources and tests
# Only take into account files in a test directory for test files
# Exclude files in a test directory from the main source files
Anyway, I think the root cause is that you are specifying the absolute path of the source and test inclusions/exclusions while they should be relative to the BaseDir. please make them relative and let me know if you still face the issue.
for example: -Dsonar.test.inclusions=/home/project/test/files/test.c
should be -Dsonar.test.inclusions=/project/test/files/test.c
@Abbas_Sabra , thank you, it was that exactly. I was following this documentation and it didn’t metion the relative paths. But it worked.
However, I do have on question, if I can use this topic. Regarding the generic xml format, is file path mandatory or can be a way to ignore it? Since we are running bazel test for our unit tests, our test rule can have more than one src file, therefor, more than one file path.