Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHPUnitResultFormatter] Added warning and risky counter #1435

Merged
merged 2 commits into from
Nov 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ abstract class PHPUnitResultFormatter7 implements PHPUnit\Framework\TestListener
* @var array
*/
private $warningCounts = [];
private $riskyCounts = [];

/**
* Constructor
Expand Down Expand Up @@ -119,6 +120,7 @@ public function startTestRun()
$this->warningCounts = [0];
$this->incompleteCounts = [0];
$this->skipCounts = [0];
$this->riskyCounts = [0];
}

public function endTestRun()
Expand All @@ -136,6 +138,8 @@ public function startTestSuite(PHPUnit\Framework\TestSuite $suite): void
$this->errorCounts[] = 0;
$this->incompleteCounts[] = 0;
$this->skipCounts[] = 0;
$this->warningCounts[] = 0;
$this->riskyCounts[] = 0;
}

/**
Expand All @@ -158,6 +162,12 @@ public function endTestSuite(PHPUnit\Framework\TestSuite $suite): void
$lastSkipCount = array_pop($this->skipCounts);
$this->skipCounts[count($this->skipCounts) - 1] += $lastSkipCount;

$lastWarningCount = array_pop($this->warningCounts);
$this->warningCounts[count($this->warningCounts) - 1] += $lastWarningCount;

$lastRiskyCount = array_pop($this->riskyCounts);
$this->riskyCounts[count($this->riskyCounts) - 1] += $lastRiskyCount;

array_pop($this->timers);
}

Expand Down Expand Up @@ -237,6 +247,7 @@ public function addSkippedTest(PHPUnit\Framework\Test $test, Throwable $e, float
*/
public function addRiskyTest(PHPUnit\Framework\Test $test, Throwable $e, float $time): void
{
$this->riskyCounts[count($this->riskyCounts) - 1]++;
}

/**
Expand All @@ -263,6 +274,14 @@ public function getWarningCount()
return end($this->warningCounts);
}

/**
* @return mixed
*/
public function getRiskyCount()
{
return end($this->riskyCounts);
}

/**
* @return mixed
*/
Expand Down