Search code examples
phpphpunitcontinuous-integrationshippable-ci

Shippable Branch Coverage always 0.00%


I am testing phpunit tests with Shippable CI but I always get 0.00% in Branch Coverage while Sequence Coverage is 100%.

This is my shippable.yml:

language: php

php: 
    - 5.4

before_script: 
    - mkdir -p shippable/testresults
    - mkdir -p shippable/codecoverage
    - mysql -e 'create database if not exists test;'

script:
  - phpunit  --log-junit shippable/testresults/junit.xml --coverage-xml shippable/codecoverage test.php

This is sql.php:

  class SQL {
      public static function main($bool) {
         $test = 5;
         $tmp = 0;

         if($bool + $test >= 10){
            $tmp = 10;
         }else{
            $tmp = 77;
         }

         if($tmp == 10){
            return true;
         }

         return false;
   }
 }

This is my test.php:

    class SQLTest extends PHPUnit_Framework_TestCase {
        public function test() {
          $sql = new SQL();
          $doc = $sql->main(3);
          $this->assertEquals(false, $doc);
        }

        public function test2() {
          $sql = new SQL();
          $doc = $sql->main(8);
          $this->assertEquals(true, $doc);
        }

        public function testBla(){
          $test = "string";
          $this -> assertEquals($test, "string");
        }
    }

Do I have to do any extra configuration or is 0.00% really correct? Thanks!


Solution

  • I have asked the Shippable Support and they said:

    PHPUnit did not support branch coverage until recently, so our parser does not output branch coverage metrics for PHPUnit. From the PHPUnit docs, it does look like they might have added support for branch coverage; will open this as a feature request internally to find out if this is now in a parseable format.

    https://github.com/Shippable/support/issues/1929