/**
* Run the registered tests, and output a report
*
* @param boolean $report whether or not to output a report after tests run. Default true.
* @param string $filter optional test case name filter
* @see FUnit::run_tests()
* @see FUnit::report()
*/
public static function run($report = true, $filter = null, $report_format = null)
{
// create a new current suite if needed
static::check_current_suite();
// get the suite
$suite = static::get_current_suite();
if (static::$disable_run) {
FUnit::debug_out("Not running tests because of \$disable_run");
return;
}
// set handlers
$old_error_handler = set_error_handler('\\FUnit::error_handler');
// run the tests in the suite
FUnit::debug_out("Running tests in suite '" . $suite->getName() . "'");
$run_tests = $suite->run($filter);
if (static::$disable_reporting) {
FUnit::debug_out("Reporting disabled");
$report = false;
}
if ($report) {
FUnit::debug_out("Printing report for tests run in suite '" . $suite->getName() . "'");
static::report($report_format, $run_tests);
} else {
FUnit::debug_out("Not printing report for tests run in suite '" . $suite->getName() . "'");
}
// add this suite's data to the static $all_run_tests
static::$all_run_tests = array_merge(static::$all_run_tests, $run_tests);
// restore handlers
if ($old_error_handler) {
set_error_handler($old_error_handler);
}
$exit_code = $suite->getExitCode();
static::$current_suite_name = null;
return $exit_code;
}