Closed thekid closed 6 years ago
Implements #33
Inside a listener's testRunFinished() method, call the metric() method. Here's an example from the coverage library:
testRunFinished()
class CoveredLines extends Metric { private $coverage, $executed, $executable; public function __construct($coverage) { $this->coverage= $coverage; } protected function calculate() { $report= $this->coverage->getReport(); $this->executed= $report->getNumExecutedLines(); $this->executable= $report->getNumExecutableLines(); } protected function format() { $percent= $this->executed / $this->executable * 100; return sprintf( "%s%.2f%%\033[0m lines covered (%d/%d)", $percent < 50.0 ? "\033[31;1m" : ($percent < 90.0 ? "\033[33;1m" : "\033[32;1m"), $percent, $this->executed, $this->executable ); } protected function value() { return $this->executed / $this->executable * 100; } } $result->metric('Coverage', new CoveredLines($this->coverage));
Implements #33
Usage
Inside a listener's
testRunFinished()
method, call the metric() method. Here's an example from the coverage library:Example