peridot-php / peridot

Event driven BDD test framework for PHP
http://peridot-php.github.io/
MIT License
328 stars 27 forks source link

include accessors to test result counts #133

Closed brianium closed 9 years ago

brianium commented 9 years ago

Adding accessors to a few properties of this key model :)

It seemed appropriate to have setters available for this model. My use case came up in the concurrency plugin when trying to get an appropriate exit code. We currently set the exit code like this in Command:

$result = new TestResult($this->eventEmitter);
$this->getLoader()->load($this->configuration->getPath());
$this->factory->create($this->configuration->getReporter());
$this->runner->run($result);

if ($result->getFailureCount() > 0) {
    return 1;
}

return 0;

This works for normal test results, but what about a different condition for a failure? This is the case in the concurrency plugin when a file loaded in a worker process contains PHP fatal errors. Since we can recover from those in a concurrent context, there is no need to let it bubble up and crash everything. However we still need a way to fail the suite. This should be as easy as:

$emitter->on('error', function() {
    $failures = $this->result->getFailureCount();
    $this->result->setFailureCount(++$failures);
});

Just an effective way to use a simple model :)

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.07%) to 95.26% when pulling 486b21dc9f2535d777fe0d9d356e58a62975e394 on brianium:feature/result-accessors into 9678cb120eb56a6196eedfd8829b38197f862b51 on peridot-php:master.

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.07%) to 95.26% when pulling 486b21dc9f2535d777fe0d9d356e58a62975e394 on brianium:feature/result-accessors into 9678cb120eb56a6196eedfd8829b38197f862b51 on peridot-php:master.