/** * Starts the Code Coverage. */ public static function start() { /** * Simpletest Code Coverage depends on xdebug. * * Ensure that the xdebug extension is loaded. */ if (false === extension_loaded('xdebug')) { die('Code Coverage needs Xdebug extension. Not loaded!'); } if (false === function_exists("xdebug_start_code_coverage")) { die('Code Coverage needs the method xdebug_start_code_coverage. Not found!'); } /** * Simpletest Code Coverage depends on sqlite. * * Ensure that the sqlite extension is loaded. */ if (false === class_exists('SQLiteDatabase')) { echo 'Code Coverage needs the php extension SQLITE. Not loaded!'; } /** * Setup Simpletest Code Coverage. */ require_once 'simpletest/extensions/coverage/coverage.php'; $coverage = new CodeCoverage(); $coverage->log = 'coverage.sqlite'; $coverage->root = TESTSUBJECT_DIR; $coverage->includes[] = '.*\\.php$'; $coverage->excludes[] = 'simpletest'; $coverage->excludes[] = 'tests'; $coverage->excludes[] = 'libraries'; $coverage->excludes[] = 'coverage-report'; $coverage->excludes[] = 'sweety'; $coverage->excludes[] = './.*.php'; $coverage->maxDirectoryDepth = 1; $coverage->resetLog(); $coverage->writeSettings(); /** * Finally: let's start the Code Coverage. */ $coverage->startCoverage(); #echo 'Code Coverage started...'; self::$coverage = $coverage; }
$success = false; // Tests -> determine, if we are in commandline mode, then output pure text if (TextReporter::inCli()) { // fetch reporter #require_once 'simpletest/extensions/colortext_reporter.php'; require_once 'simpletest/extensions/junit_xml_reporter.php'; ob_start(); #$reporter = new TextReporter(); #$reporter = new ColorTextReporter(); $reporter = new JUnitXmlReporter(); // hand reporter to the testsuite and run it $success = $testsuite->run($reporter); // write test results to xml file file_put_contents(__DIR__ . '/test-results.xml', ob_get_contents()); ob_end_clean(); // do not let the tests fail, the fail status is evaluated via xml file $success = true; } else { // display nice html report $success = $testsuite->run(new Reporter()); } // stop CodeCoverage if (PERFORM_CODECOVERAGE == true) { Clansuite_CodeCoverage::stop(); Clansuite_CodeCoverage::getReport(); } // Tests -> exit with status if (false === $success) { // Exit with error code to let the build fail, when the test is unsuccessfull. exit(1); }