/** * {@inheritdoc} * * @param TestResult $result */ public function run(TestResult $result) { $this->eventEmitter->on('test.failed', function () { if ($this->configuration->shouldStopOnFailure()) { $this->eventEmitter->emit('suite.halt'); } }); $this->eventEmitter->emit('runner.start'); $this->suite->setEventEmitter($this->eventEmitter); $start = microtime(true); $this->suite->run($result); $this->eventEmitter->emit('runner.end', [microtime(true) - $start]); }
/** * {@inheritdoc} * * @param TestResult $result */ public function run(TestResult $result) { $this->handleErrors(); $this->eventEmitter->on('test.failed', function () { if ($this->configuration->shouldStopOnFailure()) { $this->eventEmitter->emit('suite.halt'); } }); $this->eventEmitter->emit('runner.start'); $this->suite->setEventEmitter($this->eventEmitter); $this->suite->run($result); $this->eventEmitter->emit('runner.end'); restore_error_handler(); }
}); $failingChild = new Test("failing child", function () { throw new Exception("booo"); }); $passing2Child = new Test("passing2 child", function () { }); $childSuite->addTest($passingChild); $childSuite->addTest($failingChild); $childSuite->addTest($passing2Child); $suite->addTest($childSuite); $passing2 = new Test("passing2 spec", function () { }); $suite->addTest($passing2); $configuration = new Configuration(); $configuration->stopOnFailure(); $suite->setEventEmitter($this->eventEmitter); $runner = new Runner($suite, $configuration, $this->eventEmitter); $result = new TestResult($this->eventEmitter); $runner->run($result); assert($result->getTestCount() === 3, "spec count should be 3"); }); }); $behavesLikeErrorEmitter = function () { $this->suite->addTest(new Test("my spec", function () { trigger_error("This is a user notice", E_USER_NOTICE); })); $error = []; $this->eventEmitter->on('error', function ($errno, $errstr, $errfile, $errline) use(&$error) { $error = array('errno' => $errno, 'errstr' => $errstr, 'errfile' => $errfile, 'errline' => $errline); }); $this->runner->run(new TestResult(new EventEmitter()));
/** * Create a Suite based on the state of the Context. * * @param $description * @param callable $fn * @param $pending * @return Suite */ private function createSuite($description, callable $fn, $pending) { $suite = new Suite($description, $fn); if ($pending !== null) { $suite->setPending($pending); } $suite->setFile($this->file); $suite->setEventEmitter($this->getEventEmitter()); return $suite; }