PHPUnit + Sonarqube exported coverage do not match with actual xml result -


sonarqube: 5.1.2 sonar-runner: 2.2.1 php plugin: 2.6 phpunit 4.2.6

we're running phpunit on our application i'm not able correct coverage % on sonar expected.

in phpunit.xml have filters defining folders want cover.

<whitelist adduncoveredfilesfromwhitelist="false">             <directory>./site-library-php/src/main/php/babelcentral/model/content</directory>         </whitelist> 

in sonar properties

sonar.modules=php-module php-module.sonar.phpunit.coverage.analyzeonly=true php-module.sonar.phpunit.analyzeonly=true php-module.sonar.php.tests.reportpath=site-main-php/src/test/target/reports/phpunit.xml php-module.sonar.php.coverage.reportpath=site-main-php/src/test/target/reports/phpunit.coverage.xml 

viewing log on jenkins, tests seem run fine , ends with:

tests: 1479, assertions: 4165, failures: 58, incomplete: 14, skipped: 55.  generating code coverage report in clover xml format ... done  generating code coverage report in html format ... done // further down 11:47:51.973 info  - analyzing phpunit test report: site-main-php/src/test/target/reports/phpunit.xml org.sonar.plugins.php.phpunit.phpunitresultparser@35e7e715 11:47:52.604 info  - analyzing phpunit unit test coverage report: site-main-php/src/test/target/reports/phpunit.coverage.xml phpunit unit test coverage result parser 

all seems working well. however, sonar report different result, covering entire source folder. these number shown on dashboard.

unit tests coverage 1.8% line coverage 1.8% unit test success 95.9%  

is there anyway have sonar respect phpunit's configured filter?

note: i'm able achieve desired numbers on coverage if explicitly set

php-module.sonar.sources 

to directories/files want. it's that, comma-separated config hard manage phpunit's xml config.

defining set of source files should analysed sonarqube crucial: it's on set of files coding rules applied , metrics computed. sonar.sources therefore mandatory property , main way configure set of source files.

other properties may used refine set of source files:

  • you may configure sonar.tests: test files automatically excluded sonar.sources.
  • you may have exclude other php files dependencies or generated code sonar.exclusions.

you should aware several plugins may contribute global coverage of project: if installed javascript plugin , if sonar.sources contains javascript files, taken account when calculating coverage metrics.

if you're interested in adjusting coverage, can exclude files coverage metrics sonar.coverage.exclusions.


Comments

Popular posts from this blog

How to show in django cms breadcrumbs full path? -

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -