function AllTests() { $reporter = new HtmlCoverageReporter("CASHMusic Code Coverage", "", "report"); $includePaths = array("core", "installers", "interface"); $excludePaths = array("tests"); $cov = new CoverageRecorder($includePaths, $excludePaths, $reporter); $cov->startInstrumentation(); $this->TestSuite('All tests'); // this sucks. We should auto-add anything in tests/php/*.php $this->addFile('tests/php/001_BasicTests.php'); $this->addFile('tests/php/002_CASHConnection.php'); // $this->addFile('tests/php/003_CASHDBA.php'); // Since test failures stop the test suite, if we get here, all // tests passed. This lets Jitterbug know what is up. print "Result: PASS\n"; // this is probably not the right place for this $cov->stopInstrumentation(); $cov->generateReport(); $reporter->printTextSummary(); }
*/ /** * This file should be executed with following command * Linux: * $ (export PHPCOVERAGE_HOME=/path/to/phpcoverage/src; php codeCoverageMain.php) * Windows: * > set PHPCOVERAGE_HOME=/path/to/phpcoverage/src * > php codeCoverageMain.php * */ #require_once "phpcoverage.inc.php"; #define("PHPCOVERAGE_HOME", "/var/git/gus-dev/php/http/phpcoverage/src"); define("PHPCOVERAGE_HOME", "../../src"); require_once PHPCOVERAGE_HOME . "/CoverageRecorder.php"; require_once PHPCOVERAGE_HOME . "/reporter/HtmlCoverageReporter.php"; $reporter = new HtmlCoverageReporter("Code Coverage Report", "", "report"); #$includePaths = array("."); #$excludePaths = array("codeCoverageMain.php", "test_driver.php"); #$includePaths = array("/var/git/gus-dev/php/http/system/application/controllers/" . $argv[1] . ".php"); if ($argv[1] == "test") { $includePaths = array("../../../system/application/controllers/" . $argv[1] . ".php", "../../../system/application/models/"); } else { $includePaths = array("../../../system/application/controllers/" . $argv[1] . ".php"); } $excludePaths = array(""); $cov = new CoverageRecorder($includePaths, $excludePaths, $reporter); $cov->startInstrumentation(); #include "test_driver.php"; #include "/var/git/gus-dev/php/http/index.php"; include "../../../index.php"; $cov->stopInstrumentation();
$covReporter = new HtmlCoverageReporter($OPTION['report-name'], "", $OPTION["report-dir"]); // // Notice the coverage recorder is of type RemoteCoverageRecorder // $cov = new RemoteCoverageRecorder($includePaths, $excludePaths, $covReporter); $cov->generateReport($xmlUrl, true); $covReporter->printTextSummary($OPTION["report-dir"] . "/report.txt"); // Should the summary be printed to console ? if (isset($OPTION['print-summary']) && $OPTION['print-summary']) { $covReporter->printTextSummary(); } } else { // // Configure reporter, and generate the PHPCoverage report // $covReporter = new HtmlCoverageReporter($OPTION['report-name'], "", $OPTION["report-dir"]); $cov = new CoverageRecorder($includePaths, $excludePaths, $covReporter); $cov->startInstrumentation(); echo "\n>>>>>>>>>>>>>>>>>>> Output from the test driver begins\n\n"; include $OPTION['test-driver']; echo "\n\nOutput from the test driver ends <<<<<<<<<<<<<<<<<<<<<\n"; $cov->stopInstrumentation(); $cov->generateReport(); $covReporter->printTextSummary($OPTION["report-dir"] . "/report.txt"); // Should the summary be printed to console ? if (isset($OPTION['print-summary']) && $OPTION['print-summary']) { $covReporter->printTextSummary(); } } } else { if ($OPTION['cleanup']) {
/** * Generate the static report * * Overrided to generate the serialised object to be displayed inline * with the test results. * * @param &$data Reference to Coverage Data */ public function generateReport(&$data) { parent::generateReport($data); // head data $data = new stdClass(); $data->time = time(); $data->title = $this->heading; $data->output = $this->outputDir; // summary data $data->totalfiles = $this->grandTotalFiles; $data->totalln = $this->grandTotalLines; $data->totalcoveredln = $this->grandTotalCoveredLines; $data->totaluncoveredln = $this->grandTotalUncoveredLines; $data->totalpercentage = $this->getGrandCodeCoveragePercentage(); // file details data $data->coveragedetails = $this->fileCoverage; // save serialised object file_put_contents($data->output . '/codecoverage.ser', serialize($data)); }
<?php require 'simpletest/unit_tester.php'; require 'simpletest/mock_objects.php'; require 'simpletest/reporter.php'; define('MIO_PATH', realpath(dirname(__FILE__) . '/../') . '/'); require 'spikecoverage/CoverageRecorder.php'; require 'spikecoverage/reporter/HtmlCoverageReporter.php'; $coverage_reporter = new HtmlCoverageReporter("Code Coverage Report", "", "reports"); $include = array(MIO_PATH); $exclude = array(MIO_PATH . "tests", MIO_PATH . "example"); $coverage_recorder = new CoverageRecorder($include, $exclude, $coverage_reporter); $group = new GroupTest('All Muliplexing I/O Tests'); $dir = opendir(MIO_PATH . '/tests'); while ($file = readdir($dir)) { if (is_file($file) && substr($file, 0, 1) != '.' && $file != 'testRunner.php') { require MIO_PATH . 'tests/' . $file; $class = 'Mio' . substr($file, 0, -4); $group->addTestClass(new $class()); } } $coverage_recorder->startInstrumentation(); $group->run(new TextReporter()); $coverage_recorder->stopInstrumentation(); $coverage_recorder->generateReport(); $coverage_reporter->printTextSummary();
$web_url = "http://localhost/coverage/"; $cov_url = $web_url . "phpcoverage.remote.top.inc.php"; // Session 1 file_get_contents($cov_url . "?phpcoverage-action=init&cov-file-name=" . urlencode("phpcoverage.data.xml") . "&tmp-dir=" . urlencode("/tmp")); $str = file_get_contents($web_url . "sample.php"); file_put_contents("/tmp/data1.xml", file_get_contents($cov_url . "?phpcoverage-action=get-coverage-xml")); file_get_contents($cov_url . "?phpcoverage-action=cleanup"); // Session 2 file_get_contents($cov_url . "?phpcoverage-action=init&cov-file-name=" . urlencode("phpcoverage.data2.xml") . "&tmp-dir=" . urlencode("/tmp")); $str = file_get_contents($web_url . "sample2.php"); file_put_contents("/tmp/data2.xml", file_get_contents($cov_url . "?phpcoverage-action=get-coverage-xml")); file_get_contents($cov_url . "?phpcoverage-action=cleanup"); // Session 3 file_get_contents($cov_url . "?phpcoverage-action=init&cov-file-name=" . urlencode("phpcoverage.data.xml") . "&tmp-dir=" . urlencode("/tmp")); $str = file_get_contents($web_url . "sample.php"); file_put_contents("/tmp/data3.xml", file_get_contents($cov_url . "?phpcoverage-action=get-coverage-xml")); file_get_contents($cov_url . "?phpcoverage-action=cleanup"); // Configure reporter, and generate report $covReporter = new HtmlCoverageReporter("Sample Web Test Code Coverage", "", $PHPCOVERAGE_REPORT_DIR); $excludePaths = array(); // Set the include path for the web-app // PHPCOVERAGE_APPBASE_PATH is passed on the commandline $includePaths = array(realpath($PHPCOVERAGE_APPBASE_PATH)); // Notice the coverage recorder is of type RemoteCoverageRecorder $cov = new RemoteCoverageRecorder($includePaths, $excludePaths, $covReporter); // Pass the code coverage XML url into the generateReport function //$cov->generateReport($cov_url . "?phpcoverage-action=get-coverage-xml", true); $cov->generateReport(array("/tmp/data1.xml", "/tmp/data2.xml", "/tmp/data3.xml"), true); $covReporter->printTextSummary($PHPCOVERAGE_REPORT_DIR . "/report.txt"); // Clean up // file_get_contents($cov_url . "?phpcoverage-action=cleanup");