Add running PHP unit test coverage reports in CircleCI

This commit is contained in:
Tautvidas Sipavičius
2016-08-25 00:34:58 +03:00
parent 3929efbdd9
commit efc5c34bf9
2 changed files with 19 additions and 6 deletions

View File

@ -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) {

View File

@ -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