public function run($tests) { echo '['; $failed = $ignored = []; $total = 0; $start = microtime(true); set_error_handler(function ($code, $msg, $file, $line) { if (0 !== error_reporting()) { throw new Error($msg . ' @ ' . $file . ':' . $line); } }); foreach ($tests as $name => $closure) { if ('@' === $name[0]) { continue; } if ('#' === $name[0]) { echo 'I'; $ignored[substr($name, 1)] = 'prefixed with #'; continue; } $run = new Run($tests, $closure); $run->process('before'); try { $run->invoke(); echo '.'; } catch (Failed $e) { echo 'F'; $failed[$name] = $e; } catch (\Exception $e) { echo 'E'; $failed[$name] = $e; } $run->process('after'); $total++; } $stop = microtime(true); restore_error_handler(); echo "]\n\n"; $this->summarize($total, $stop - $start, $ignored, $failed); return $failed ? 255 : 0; }