diff --git a/RoboFile.php b/RoboFile.php index 52db69a815..981546f7f1 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -114,15 +114,20 @@ class RoboFile extends \Robo\Tasks { $this->_exec($command); } - function testCoverage($file = null) { + function testCoverage($opts=['file' => null, 'xml' => false]) { $this->loadEnv(); $this->_exec('vendor/bin/codecept build'); - $this->_exec(join(' ', array( + $command = join(' ', array( 'vendor/bin/codecept run', - (($file) ? $file : ''), + (($opts['file']) ? $opts['file'] : ''), '--coverage', - '--coverage-html' - ))); + ($opts['xml']) ? '--coverage-xml' : '--coverage-html' + )); + + if($opts['xml']) { + $command .= ' --xml'; + } + $this->_exec($command); } function testJavascript($xml_output_file = null) { diff --git a/circle.yml b/circle.yml index 52ead5bb59..dd6dc27e05 100644 --- a/circle.yml +++ b/circle.yml @@ -31,6 +31,10 @@ dependencies: # Create .env file with correct path to WP installation - echo "WP_TEST_PATH=\"/home/ubuntu/mailpoet/wordpress\"" > .env + # Enable XDebug for coverage reports. + # Comment out if not running PHP coverage reports, for performance + - sed -i 's/^;//' /opt/circleci/php/$(phpenv global)/etc/conf.d/xdebug.ini + ## tests override test: override: @@ -39,7 +43,11 @@ test: - ./do t:j $CIRCLE_TEST_REPORTS/mocha/junit.xml # Run PHP tests - - ./do t:u --xml + #- ./do t:u --xml + # Uncomment to run coverage tests instead + - ./do t:c --xml # Copy the report - mkdir $CIRCLE_TEST_REPORTS/codeception - cp tests/_output/report.xml $CIRCLE_TEST_REPORTS/codeception/report.xml + # Uncomment to copy PHP coverage report + - cp tests/_output/coverage.xml $CIRCLE_TEST_REPORTS/codeception/coverage.xml