3

I am using Fastlane for building and testing my ObjC project. I use scan action to run Unit Test cases and slather action to generate Code coverage report. I am able to generate cobertura.xml report using slather action, but unable to publish the report to SonarQube.

I am using SonarQube 6.4 and fastlane 2.64.0.

FastFile

scan(
workspace: "Sample.xcworkspace",
scheme: "SampleTests",
code_coverage: true,
output_types: "html"
)
slather(
cobertura_xml: true,
output_directory: "./reports",
proj: "Sample.xcodeproj",
workspace: "Sample.xcworkspace",
scheme: "SampleTests",
)
sonar

Analysis is published to Sonar but Code Coverage report is not updated. Please let me know where i miss the key.

Velu
  • 31
  • 1
  • 2
  • Are there any error messages in the SonarQube log? – Jeroen Heier Jan 11 '18 at 05:03
  • No. There are no logs generated in SonarQube. Is there any fields to be added in sonar-project.properties for publishing the code coverage report to SonarQube – Velu Jan 11 '18 at 08:40

1 Answers1

1

From your comments on your question, it seems that you haven't tried configuring the path to the report, so it's natural that no coverage data is imported. The analysis cannot intuit where reports are or that it should read them.

Having said that, you also indicate that you're generating a cobertura.xml file, but that's not one of the formats currently supported by SonarCFamily for Objective-C. So you'll need to get your coverage data into the Generic Coverage format, and then include the path to that report using the sonar.coverageReportPaths analysis property.

G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
  • Thanks for the valuable input. Since cobertura is not supported by SonarQube, i replaced it with gcovr in fastlane. But the report generated with gcovr is 0% Code coverage. Code in fastlane gcovr( html: true, html_details: true, output: "./code-coverage/report.html" ) – Velu Jan 12 '18 at 03:06
  • Follow the site: https://sonarcloud.io/documentation/analysis/coverage/ and https://github.com/SonarSource/sonar-scanning-examples/tree/master/swift-coverage I get the error when run bash xccov-to-sonarqube-generic.sh Build/Logs/Test/*.xcresult/*_Test/*.xccovarchive/ > sonarqube-generic-coverage.xml Error Domain=DVTCommandLineParserErrorDomain Code=3 "invalid option '--archive'" UserInfo={NSLocalizedDescription=invalid option '--archive'} – biolinh Oct 22 '19 at 06:41