From ae5803ce4558f855c7d955baa2d90b93ec40c4b7 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Fri, 22 Jul 2022 16:07:17 +0200 Subject: [PATCH] Risky tests should not be counted within Errors (#684) --- src/Logging/JUnit/Reader.php | 2 +- src/Logging/JUnit/Writer.php | 2 +- test/Unit/Logging/JUnit/ReaderTest.php | 6 +++--- test/Unit/Logging/LogInterpreterTest.php | 4 ++-- test/Unit/Runners/PHPUnit/ResultPrinterTest.php | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Logging/JUnit/Reader.php b/src/Logging/JUnit/Reader.php index ffaeabb0..42c32965 100644 --- a/src/Logging/JUnit/Reader.php +++ b/src/Logging/JUnit/Reader.php @@ -82,7 +82,7 @@ private function parseTestSuite(SimpleXMLElement $node, bool $isRootSuite): Test (int) $node['tests'], (int) $node['assertions'], (int) $node['failures'], - (int) $node['errors'], + (int) $node['errors'] - $risky, (int) $node['warnings'], $risky, (int) $node['skipped'], diff --git a/src/Logging/JUnit/Writer.php b/src/Logging/JUnit/Writer.php index 274ab07b..6e935fe2 100644 --- a/src/Logging/JUnit/Writer.php +++ b/src/Logging/JUnit/Writer.php @@ -102,7 +102,7 @@ private function createSuiteNode(TestSuite $parentSuite): DOMElement $suiteNode->setAttribute('tests', (string) $parentSuite->tests); $suiteNode->setAttribute('assertions', (string) $parentSuite->assertions); - $suiteNode->setAttribute('errors', (string) $parentSuite->errors); + $suiteNode->setAttribute('errors', (string) ($parentSuite->errors + $parentSuite->risky)); $suiteNode->setAttribute('warnings', (string) $parentSuite->warnings); $suiteNode->setAttribute('failures', (string) $parentSuite->failures); $suiteNode->setAttribute('skipped', (string) $parentSuite->skipped); diff --git a/test/Unit/Logging/JUnit/ReaderTest.php b/test/Unit/Logging/JUnit/ReaderTest.php index 5cc05b24..092b85d7 100644 --- a/test/Unit/Logging/JUnit/ReaderTest.php +++ b/test/Unit/Logging/JUnit/ReaderTest.php @@ -67,7 +67,7 @@ public function testMixedSuiteShouldConstructRootSuite(): TestSuite static::assertSame(19, $suite->tests); static::assertSame(10, $suite->assertions); static::assertSame(3, $suite->failures); - static::assertSame(3, $suite->errors); + static::assertSame(1, $suite->errors); static::assertSame(1.234567, $suite->time); return $suite; @@ -225,7 +225,7 @@ public function testMixedGetTotals(): void { static::assertSame(19, $this->mixed->getTotalTests()); static::assertSame(10, $this->mixed->getTotalAssertions()); - static::assertSame(3, $this->mixed->getTotalErrors()); + static::assertSame(1, $this->mixed->getTotalErrors()); static::assertSame(3, $this->mixed->getTotalFailures()); static::assertSame(2, $this->mixed->getTotalWarnings()); static::assertSame(4, $this->mixed->getTotalSkipped()); @@ -356,7 +356,7 @@ public function testGetSkippedMessagesForSkippingDataProviders(): void public function testMixedGetFeedback(): void { - static::assertSame('EEEWWFFFRRSSSS.....', $this->mixed->getFeedback()); + static::assertSame('EWWFFFRRSSSS.......', $this->mixed->getFeedback()); } public function testRemoveLog(): void diff --git a/test/Unit/Logging/LogInterpreterTest.php b/test/Unit/Logging/LogInterpreterTest.php index eb13ee8b..00a5935c 100644 --- a/test/Unit/Logging/LogInterpreterTest.php +++ b/test/Unit/Logging/LogInterpreterTest.php @@ -54,7 +54,7 @@ public function testGetTotals(): void { static::assertSame(22, $this->interpreter->getTotalTests()); static::assertSame(13, $this->interpreter->getTotalAssertions()); - static::assertSame(3, $this->interpreter->getTotalErrors()); + static::assertSame(1, $this->interpreter->getTotalErrors()); static::assertSame(3, $this->interpreter->getTotalFailures()); static::assertSame(2, $this->interpreter->getTotalWarnings()); static::assertSame(4, $this->interpreter->getTotalSkipped()); @@ -180,7 +180,7 @@ public function testMergeReaders(): void static::assertSame(22, $oneResult->tests); static::assertSame(13, $oneResult->assertions); static::assertSame(3, $oneResult->failures); - static::assertSame(3, $oneResult->errors); + static::assertSame(1, $oneResult->errors); static::assertSame(2, $oneResult->warnings); static::assertSame(2, $oneResult->risky); static::assertSame(4, $oneResult->skipped); diff --git a/test/Unit/Runners/PHPUnit/ResultPrinterTest.php b/test/Unit/Runners/PHPUnit/ResultPrinterTest.php index 5fed5c7d..95fc5237 100644 --- a/test/Unit/Runners/PHPUnit/ResultPrinterTest.php +++ b/test/Unit/Runners/PHPUnit/ResultPrinterTest.php @@ -325,7 +325,7 @@ public function testGetFooterWithFailures(): void $footer = $this->printer->getFooter(); $eq = "FAILURES!\n"; - $eq .= "Tests: 20, Assertions: 10, Errors: 4, Failures: 3, Warnings: 2, Skipped: 4.\n"; + $eq .= "Tests: 20, Assertions: 10, Errors: 2, Failures: 3, Warnings: 2, Skipped: 4.\n"; static::assertSame($eq, $footer); } @@ -362,7 +362,7 @@ public function testPrintFeedbackForMixed(): void $this->printer->addTest($this->mixedSuite); $this->printer->printFeedback($this->mixedSuite); $contents = $this->output->fetch(); - static::assertSame("EEEWWFFFRRSSSS..... 19 / 19 (100%)\n", $contents); + static::assertSame("EWWFFFRRSSSS....... 19 / 19 (100%)\n", $contents); } public function testPrintFeedbackForMoreThan100Suites(): void