Esempio n. 1
0
 protected function logJson(Collector $collector)
 {
     $vanquishedTotal = $collector->getVanquishedTotal();
     $measurableTotal = $collector->getMeasurableTotal();
     if ($measurableTotal !== 0) {
         $detectionRateTested = round(100 * ($vanquishedTotal / $measurableTotal));
     } else {
         $detectionRateTested = 0;
     }
     if ($collector->getTotalCount() !== 0) {
         $uncoveredRate = round(100 * ($collector->getShadowCount() / $collector->getTotalCount()));
         $detectionRateAll = round(100 * ($collector->getVanquishedTotal() / $collector->getTotalCount()));
     } else {
         $uncoveredRate = 0;
         $detectionRateAll = 0;
     }
     $out = ['summary' => ['total' => $collector->getTotalCount(), 'kills' => $collector->getKilledCount(), 'escapes' => $collector->getEscapeCount(), 'errors' => $collector->getErrorCount(), 'timeouts' => $collector->getTimeoutCount(), 'notests' => $collector->getShadowCount(), 'covered_score' => $detectionRateTested, 'combined_score' => $detectionRateAll, 'mutation_coverage' => 100 - $uncoveredRate], 'escaped' => []];
     $out = array_merge($out, $collector->toGroupedMutantArray());
     file_put_contents($this->jsonLogFile, json_encode($out, JSON_PRETTY_PRINT));
 }
Esempio n. 2
0
 /**
  * Render message that mutation testing loop is starting
  *
  * @param Collector $collector
  */
 public function renderSummaryReport(Collector $collector)
 {
     $pkills = str_pad($collector->getKilledCount(), 8, ' ', STR_PAD_LEFT);
     $pescapes = str_pad($collector->getEscapeCount(), 8, ' ', STR_PAD_LEFT);
     $perrors = str_pad($collector->getErrorCount(), 8, ' ', STR_PAD_LEFT);
     $ptimeouts = str_pad($collector->getTimeoutCount(), 8, ' ', STR_PAD_LEFT);
     $pshadows = str_pad($collector->getShadowCount(), 8, ' ', STR_PAD_LEFT);
     $this->write(PHP_EOL, false);
     $this->write($collector->getTotalCount() . ' mutations were generated:');
     $this->write($pkills . ' mutants were killed');
     $this->write($pshadows . ' mutants were not covered by tests');
     $this->write($pescapes . ' covered mutants were not detected');
     $this->write($perrors . ' fatal errors were encountered');
     $this->write($ptimeouts . ' time outs were encountered');
     $this->write(PHP_EOL, false);
     $vanquishedTotal = $collector->getVanquishedTotal();
     $measurableTotal = $collector->getMeasurableTotal();
     if ($measurableTotal !== 0) {
         $detectionRateTested = round(100 * ($vanquishedTotal / $measurableTotal));
     } else {
         $detectionRateTested = 0;
     }
     if ($collector->getTotalCount() !== 0) {
         $coveredRate = round(100 * ($measurableTotal / $collector->getTotalCount()));
         $detectionRateAll = round(100 * ($vanquishedTotal / $collector->getTotalCount()));
     } else {
         $coveredRate = 0;
         $detectionRateAll = 0;
     }
     $this->write('Metrics:');
     $this->write('    Mutation Score Indicator (MSI): <options=bold>' . $detectionRateAll . '%</options=bold>');
     $this->write('    Mutation Code Coverage: <options=bold>' . $coveredRate . '%</options=bold>');
     $this->write('    Covered Code MSI: <options=bold>' . $detectionRateTested . '%</options=bold>');
     $this->write(PHP_EOL, false);
     $this->write('Remember that some mutants will inevitably be harmless (i.e. false positives).');
 }