Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code coverage not showing on Sonar dashboard #44

Open
xndou opened this issue Nov 18, 2013 · 19 comments
Open

Code coverage not showing on Sonar dashboard #44

xndou opened this issue Nov 18, 2013 · 19 comments
Labels

Comments

@xndou
Copy link

xndou commented Nov 18, 2013

coverage report xml was generated by xctool under sonar-reports directory but not showing on Sonar dashboard.
Xcode version is 5.0.

Verbose mode run-sonar.sh output showing the coverage report was recognized by Sonar runner and processed:
18:29:47.020 INFO - Sensor org.sonar.plugins.objectivec.coverage.CoberturaSensor@37bce5dc...
18:29:47.030 INFO - Processing coverage report /ffas/workspaces/FFAS_Mobile_Framework_Sonar/FFASMobileFramework/FIDApp/src/FIDApp/sonar-reports/coverage-FIDApp.xml
18:29:47.037 INFO - Sensor org.sonar.plugins.objectivec.coverage.CoberturaSensor@37bce5dc done: 17 ms

@cyrilpicat
Copy link
Contributor

thanks for your feedback.

there is a problem with the code coverage and Xcode 5, I guess this is your problem: #39

You can check the content of your coverage-FIDApp.xml file, I guess it is almost empty, right?

@xndou
Copy link
Author

xndou commented Dec 6, 2013

The coverage file is not empty. It has every class entry in it. I had to tweak the xctool/xcodebuild command line switch a little bit. When I use the gcovr commandline with html output option I can see real coverage. If you would like a copy of the coverage file for testing purpose let me know. I can also send you zipped up sonar-reports folder.

@cyrilpicat
Copy link
Contributor

In this case, yes, I am interested in your input.

I am interested both in:

  • the verbose log of run-sonar.sh (-v), your sonar-project.properties and the content of your sonar-reports folder generated with the original run-sonar.sh script (no tweaks)
  • the tweaks you did in the command line to make it work

If you could you make a Gist with all that, that would be perfect!

I realize I should add a troubleshooting section on GitHub also to make things easier to report.

@xndou
Copy link
Author

xndou commented Dec 16, 2013

I have uploaded related files to:
https://gist.github.com/xndou/7990501

run-sonar-new.sh is a modified version of run-sonar.sh, where we had to put temporary workaround for OCLint.
we found the xctool reporter json-compilation-database does not generate comiple-commands.json which is needed for downstream processing by OCLint. The workaround we used is to replace it with xcodebuild and oclint-xcodebuild combination to generate the json-compilation-database file:
xcodebuild → xcodebuild.log → oclint-xcodebuild → compile-commands.json

Because Xcode5 by default doesn't generate coverage files, we found a workaround of including XCTest+GCovFlush.h and XCTest+GCovFlush.m in our xcode project. This looks like triggers the flushing our of the gcc coverage files and we were able to see the coverage in both xml and html (manually generated by gcovr)

@cyrilpicat
Copy link
Contributor

sorry for the delay, I just looked at your issue again. It seems you had 2 issues, right?

  • 1st issue: code coverage. It seems you have fixed this issue with the XCTest+GCovFlush.h/.m files. If this is the case, I will close the issue and mark it as a duplicate of Coverage reported is 0% with Xcode 5 #39 and add a reference to your solution (https://github.com/leroymattingly/XCode5gcovPatch). Could you confirm me this is the case?
  • 2nd issue: OCLint. Could you file a new issue for this one, and reference your Gist? It seems like a different problem, right?

@xndou
Copy link
Author

xndou commented Jan 20, 2014

I have filed a separate issue #48 about OCLint.

About coverage, our workaround (with XCTest+GCovFlush.h/.m) only solves part of the problem, up to the point we can get coverage XML. However, seems Sonar runner is NOT picking up the xml report, therefore we are not seeing coverage in Sonar dashboard. Let me know if provided information (source code and log) is suffcient:
https://gist.github.com/xndou/7990501

@philiplb
Copy link

I think I'm getting the same error:
Code Coverage seems to run fine, I get a proper XML-File which is also parsed according to the sonar-runner log but no coverage appears in the Sonar.
Any chance that you will have a look at this issue any time soon?

@KabraBoja
Copy link

Hi, I'm getting the same error too. My coverage file is properly created in ${ROOT_PROJECT_DIRECTORY}/sonar-reports/coverage-.xml after running the run-sonar.sh script. The file is not empty but it seems that sonar can't find it (even i force the path in Sonar project Objective-C settings). Maybe is more related about the Sonar plugin than the script.

Thank you for your support!

@markaurelius
Copy link

Yea, looks like we're running into a similar issue. We get unit tests to run (and show 100% success), and a nice cobertura coverage report is generated, but no coverage data is showing in the Sonar app

@Panajev
Copy link

Panajev commented Apr 9, 2014

Same thing here... :(...

@markaurelius
Copy link

I was seeing the problem with SonarQube 4.2

When I switched to 3.7.4, things were working.

Maybe give that a shot?

@Panajev
Copy link

Panajev commented Apr 9, 2014

Potentially, but it depends on what your organization is running.

Also, for the people installing it through brew you are automatically pushed the 4.2 release.

[web [iPhone msg]]

On 09/apr/2014, at 23:51, markaurelius [email protected] wrote:

I was seeing the problem with SonarQube 4.2

When I switched to 3.7.4, things were working.

Maybe give that a shot?


Reply to this email directly or view it on GitHub.

@tunix
Copy link
Contributor

tunix commented Jun 16, 2014

Any solutions to this?

@JoeF76
Copy link

JoeF76 commented Aug 12, 2014

Having a similar problem myself.
I've tested three instances of SonarQube... our 'production' version which is currently 4.3, and local installs of 4.4 and 3.7.4 LTS. The only version that shows Unit Test coverage is 3.7.4 LTS.

... looks like I need to stick to the LTS version, unless anyone has found a fix?

@danshim
Copy link

danshim commented Nov 17, 2015

Having a similar problem. It is, in fact, multifold:

  1. Since upgrading to Xcode 7.*, the coverage files indicate extremely large hit numbers, e.g.:
    and the tool chokes on those numbers.

  2. Even after sanitizing the cobertura file, NOTHING is uploaded to the server even though the processing seems to have been successful :

Sensor org.sonar.plugins.objectivec.coverage.CoberturaSensor@7136d1b3
10:34:34.506 INFO - Processing coverage report /Users/me/Documents/src/repo3/sonar-reports/coverage-CompanionApp.xml

  • and -
    Saving measures for /Users/...

The cobertura XML file is NOT empty.

Any idea?

Thanks,
Daniel

@akshaysyaduvanshi
Copy link

Facing similar problem with Xcode 7.x
Cobertura Coverage report is generated and sonar runner also processes the coverage.xml report.
Using slather to generate to cobertura report.
But it is not visible on sonar dashboard.
Did anyone find the solution to this issue?

@hrskrs
Copy link

hrskrs commented Jan 28, 2016

Facing same issue with Xcode 7.x. Eventhough the cobertura.xml file is generated successfully (not empty) and sonar-runner not giving any error or any log that failed to parse cobertura.xml file (in debugging mode also).

fyi: Cobertura plugin is also installed and i am using a build from PR#79.

Sonar: 5.3
Sonar-runner: 2.4
Objective C plugin: 0.5-SNAPSHOT (PR#79)

@akshaysyaduvanshi
Copy link

Even i was facing the same problem. But late it got solved.
Issue was i was running slather and sonar-runner in different directory.
Make sure you run both the commands in the same directory.

@ian-whitestone
Copy link

Any updates on this?
I'm running into the same issues as people have mentioned above. In the sonar logs it shows that is succesfully parses the coverage report:

INFO: Python unit test coverage

INFO: Parsing report '/home/jenkins/workspace/eaver_leeroy-jenkins_master-XUBHYHOCJ2BSAGFITIJQAXB2GR7VRGBRZCATBWJNZEXK53CTDGSQ/coverage.xml'
INFO: Python integration test coverage
INFO: Python overall test coverage
INFO: Sensor Python Squid Sensor (done) | time=136ms
INFO: Sensor Embedded CSS Analyzer Sensor
INFO: 0 source files to be analyzed
INFO: Sensor Embedded CSS Analyzer Sensor (done) | time=215ms

I even printed the coverage.xml file previously in my jenkins pipeline and it looks fine:

<?xml version="1.0" ?>
<coverage branch-rate="1" branches-covered="0" branches-valid="0" complexity="0" line-rate="0.8571" lines-covered="6" lines-valid="7" timestamp="1515797369275" version="4.4.2">
	<!-- Generated by coverage.py: https://coverage.readthedocs.io -->
	<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
	<sources>
		<source>/leeroy-jenkins/leeroy</source>
	</sources>
	<packages>
		<package branch-rate="1" complexity="0" line-rate="0.8571" name=".">
			<classes>
				<class branch-rate="1" complexity="0" filename="__init__.py" line-rate="1" name="__init__.py">
					<methods/>
					<lines/>
				</class>
				<class branch-rate="1" complexity="0" filename="module1.py" line-rate="0.8571" name="module1.py">
					<methods/>
					<lines>
						<line hits="1" number="1"/>
						<line hits="1" number="2"/>
						<line hits="1" number="3"/>
						<line hits="0" number="4"/>
						<line hits="1" number="5"/>
						<line hits="1" number="6"/>
						<line hits="1" number="7"/>
					</lines>
				</class>
			</classes>
		</package>
	</packages>
</coverage>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests