PHPUnit test coverage from PHPUnit not being picked up with. Giving Project:null error

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

PHPUnit test coverage from PHPUnit not being picked up with. Giving Project:null error

topagae
This post has NOT been accepted by the mailing list yet.
Hello, I'm currently running a few tests on PHPUnit 4.2.5. I'm generating the clover reports as per the Sonar docs, and I'm passing them to sonar through the sonar project properties and here's the output:
   
     [exec]
     [exec] .......
     [exec]
     [exec] Time: 6.98 seconds, Memory: 20.75Mb
     [exec]
     [exec] OK (7 tests, 18 assertions)
     [exec]
     [exec] Generating code coverage report in Clover XML format ... done

So this file gets generated and looks more or less well formed when I open it and take a look. When I call Sonar runner I get this on Jenkins:

15:55:42.153 INFO  - Sensor PHPUnit Sensor...
15:55:42.153 INFO  - Analyzing PHPUnit tests report: tools/phing/build/logs/phpunit.integration.xml
15:55:42.277 INFO  - Analyzing PHPUnit coverage report: tools/phing/build/coverage/phpunit-xml-coverage.xml
15:55:43.312 INFO  - Project: null
15:55:43.368 INFO  - Sensor PHPUnit Sensor done: 1215 ms

And of course Sonar doesn't pick up the coverage, but picks up the unit tests just fine. Here's my configuration for sonar atm:

# Path to source directories (required)
# (All paths are relative to Jenkins' 'workspace').
# I originally included all the Drupal source, but PHP Depend would suck up all
# the memory on the system and fail when there were more than ~300 files.
sonar.sources=site

# The language of the project.
sonar.language=php

#Unit tests?
sonar.tests=tests

# Encoding of the source code
sonar.sourceEncoding=UTF-8

# File suffixes to check
sonar.php.file.suffixes=php,php3,php4,php5,inc,module,install

# Files to exclude
#sonar.exclusions=**/*.features.*,**/*.field_group.inc,**/*.strongarm.inc,**/*.views_default.inc

# PHPMD
sonar.phpPmd.analyzeOnly=true
sonar.phpPmd.reportPath=logs/php-md.xml

# PHP CodeSniffer
sonar.phpCodesniffer.analyzeOnly=true
sonar.phpCodesniffer.reportPath=logs/codesniffer.xml

# Reusing PHPUnit reports
sonar.php.coverage.reportPath=tools/phing/build/coverage/phpunit-xml-coverage.xml
sonar.php.tests.reportPath=tools/phing/build/logs/phpunit.integration.xml

# To deactivate features related to unit tests execution and coverage
sonar.dynamicAnalysis=false

I read a post from a while ago mentioning that it may have trouble with lots of different test files which seems incorrect. Either way I updated PHPUnit from 3.7 to 4.2 at the advice of the post but this did not solve the issue though it did make my tests slightly better.

Right now I'm trolling the code here: https://github.com/SonarCommunity/sonar-php/blob/master/sonar-php-plugin/src/main/java/org/sonar/plugins/php/phpunit/PhpUnitCoverageResultParser.java

And from the output it seems like there might be an issue with the xml phpunit is spitting out, but I'm not 100% of the issue, or how to fix it. Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: PHPUnit test coverage from PHPUnit not being picked up with. Giving Project:null error

topagae
This post has NOT been accepted by the mailing list yet.
Just bumping this because we're still having this issue after several weeks. Wanna get Sonar on all our projects.