Skip to content

Commit

Permalink
Add warnings to JUnit report - closes #3793
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRuf authored and sebastianbergmann committed Oct 28, 2019
1 parent 6568445 commit e7b8576
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Util/Log/JUnit.php
Expand Up @@ -62,6 +62,11 @@ final class JUnit extends Printer implements TestListener
*/
private $testSuiteErrors = [0];

/**
* @var int[]
*/
private $testSuiteWarnings = [0];

/**
* @var int[]
*/
Expand Down Expand Up @@ -128,7 +133,7 @@ public function addError(Test $test, \Throwable $t, float $time): void
public function addWarning(Test $test, Warning $e, float $time): void
{
$this->doAddFault($test, $e, $time, 'warning');
$this->testSuiteFailures[$this->testSuiteLevel]++;
$this->testSuiteWarnings[$this->testSuiteLevel]++;
}

/**
Expand Down Expand Up @@ -208,6 +213,7 @@ public function startTestSuite(TestSuite $suite): void
$this->testSuiteTests[$this->testSuiteLevel] = 0;
$this->testSuiteAssertions[$this->testSuiteLevel] = 0;
$this->testSuiteErrors[$this->testSuiteLevel] = 0;
$this->testSuiteWarnings[$this->testSuiteLevel] = 0;
$this->testSuiteFailures[$this->testSuiteLevel] = 0;
$this->testSuiteSkipped[$this->testSuiteLevel] = 0;
$this->testSuiteTimes[$this->testSuiteLevel] = 0;
Expand All @@ -233,6 +239,11 @@ public function endTestSuite(TestSuite $suite): void
(string) $this->testSuiteErrors[$this->testSuiteLevel]
);

$this->testSuites[$this->testSuiteLevel]->setAttribute(
'warnings',
(string) $this->testSuiteWarnings[$this->testSuiteLevel]
);

$this->testSuites[$this->testSuiteLevel]->setAttribute(
'failures',
(string) $this->testSuiteFailures[$this->testSuiteLevel]
Expand All @@ -252,6 +263,7 @@ public function endTestSuite(TestSuite $suite): void
$this->testSuiteTests[$this->testSuiteLevel - 1] += $this->testSuiteTests[$this->testSuiteLevel];
$this->testSuiteAssertions[$this->testSuiteLevel - 1] += $this->testSuiteAssertions[$this->testSuiteLevel];
$this->testSuiteErrors[$this->testSuiteLevel - 1] += $this->testSuiteErrors[$this->testSuiteLevel];
$this->testSuiteWarnings[$this->testSuiteLevel - 1] += $this->testSuiteWarnings[$this->testSuiteLevel];
$this->testSuiteFailures[$this->testSuiteLevel - 1] += $this->testSuiteFailures[$this->testSuiteLevel];
$this->testSuiteSkipped[$this->testSuiteLevel - 1] += $this->testSuiteSkipped[$this->testSuiteLevel];
$this->testSuiteTimes[$this->testSuiteLevel - 1] += $this->testSuiteTimes[$this->testSuiteLevel];
Expand Down

0 comments on commit e7b8576

Please sign in to comment.