octo-technology / sonar-objective-c

Sonar Plugin for Objective C
517 stars 206 forks source link

Code coverage not showing on Sonar dashboard #44

Open xndou opened 11 years ago

xndou commented 11 years ago

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 commented 11 years ago

thanks for your feedback.

there is a problem with the code coverage and Xcode 5, I guess this is your problem: https://github.com/octo-technology/sonar-objective-c/issues/39

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

xndou commented 11 years ago

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 commented 10 years ago

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

I am interested both in:

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 commented 10 years ago

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 commented 10 years ago

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

xndou commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

Same thing here... :(...

markaurelius commented 10 years ago

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 commented 10 years ago

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 notifications@github.com 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 commented 10 years ago

Any solutions to this?

JoeF76 commented 10 years ago

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 commented 9 years ago

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

The cobertura XML file is NOT empty.

Any idea?

Thanks, Daniel

akshaysyaduvanshi commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 6 years ago

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>