Generic Test Data XML file Results not showing - Swift

Hello, in my swift project, I’m using Quick&Nimble for test coverage. I can see my test coverage percentage in Xcode as properly.
I followed guide in here and I have created an xml file for test coverage. When I check this xml file, everything is looks pretty good, covered lines is marked as covered=true. (xml file is at attachment.)
But I cannot see the test coverage percentage in sonarcloud.
sonar scan logs are at attachment as a file. (verbose=true)
Thanks for helping. (44.5 KB) (285.0 KB)
Template for a good new topic, formatted with Markdown:

  • Bitbucket
  • sonar-scanner
    -Dsonar.swift.simulator=platform=‘iOS Simulator’,name=‘iPhone X’,OS=13.1
  • Swift

Hello @Mustafa_Yazgulu,

Welcome to the community, and well done for your first post. You upfront attached most of the useful information to troubleshoot your problem.

First thing I want to mention and that is unrelated to your problem: You can remove the sonar.swift.simulator property from your scan. It’s not needed nor used by the SonarQube Swift analyzer (it’s probably a left over from a 3rd party open source plugin :wink: )

About your problem now, the logs are demonstrating that your property is set correctly and found by the scanner, the file format seems OK too, but no coverage is extracted from it. See log below:

17:21:30.153 INFO: Parsing /Desktop/sonarqube-generic-coverage.xml
17:21:32.389 INFO: Imported coverage data for 0 files
17:21:32.389 INFO: Coverage data ignored for 979 unknown files, including:
17:21:32.389 INFO: Sensor Generic Coverage Report (done) | time=2237ms

Why is that ? A common reason is that the filenames or exact file paths do not match between the files analyzed by the scanner and the files in the coverage report.

Indeed in your case there are some visible discrepancies:

  • All your scanned files have a relatively path starting by Sources/... or Tests/...
  • In your coverage file not files have this path. The path seems to start 1 directory level below (eg Shared/...). I found 1 example of a file whose path “almost” but not “exactly” matches between the 2: AresApplication.swift
    – In the scanner logs the path is: Sources/Shared/AresApplication.swift
    – In the coverage report the path is: /Shared/AresApplication.swift

To confirm that this is the root cause, you may first manually patch the coverage file to add the Sources prefix to one files (AresApplication.swift is good, it has some coverage between lines 403 and 410), and analyze again with the patched coverage file. If the coverage is now properly reported for AresApplication.swift, the root cause is found and you can fix this on a large scale by changing the way you generate the file, to make sure the generated paths are correct: I think the problem lies in the directory from which you run the command to generate the coverage.

Hello @OlivierK
Thank you so much, for your answer. First of all, I figured out the root cause of the problem with your useful answer.
I have removed, pods and tests directories from xml file, stay only Sources directory, and removed also “/” character from begining of Sources directory in xml file. I have run scaner again, and voila! my coverage results showed up on sonarCloud.

I’m saying this to people who having same problem;
You need to check “Code” section for your project’s, directory hierarchy in sonarCloud, in your xml file, for all your files, must be same directory hierarchy.

Thank you again @OlivierK and to the community.

:+1: Glad to help ! Have fun with SonarCloud :sonarcloud:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.