From 01dc51039f15076f15ec66de33c7dcd7637a5242 Mon Sep 17 00:00:00 2001 From: Gintautas Miselis Date: Sat, 14 May 2022 23:59:36 +0300 Subject: [PATCH 1/4] Backport test.useless event from Codeception 5 Unit tests only --- src/Listener.php | 2 ++ src/ResultPrinter/HTML.php | 3 ++- src/ResultPrinter/Report.php | 2 ++ src/ResultPrinter/template/scenarios.html.dist | 6 ++++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Listener.php b/src/Listener.php index 0af5c05..7ccdcfa 100644 --- a/src/Listener.php +++ b/src/Listener.php @@ -37,6 +37,8 @@ public function __construct(EventDispatcher $dispatcher) */ public function addRiskyTest(\PHPUnit\Framework\Test $test, \Throwable $e, float $time) : void { + $this->unsuccessfulTests[] = spl_object_hash($test); + $this->fire('test.useless', new FailEvent($test, $time, $e)); } public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\AssertionFailedError $e, float $time) : void diff --git a/src/ResultPrinter/HTML.php b/src/ResultPrinter/HTML.php index 06f4b27..b570a10 100644 --- a/src/ResultPrinter/HTML.php +++ b/src/ResultPrinter/HTML.php @@ -222,7 +222,8 @@ protected function endRun():void 'successfulScenarios' => $this->successful, 'failedScenarios' => $this->failed, 'skippedScenarios' => $this->skipped, - 'incompleteScenarios' => $this->incomplete + 'incompleteScenarios' => $this->incomplete, + 'uselessScenarios' => $this->risky, ] ); diff --git a/src/ResultPrinter/Report.php b/src/ResultPrinter/Report.php index da58a78..5aef95d 100644 --- a/src/ResultPrinter/Report.php +++ b/src/ResultPrinter/Report.php @@ -26,6 +26,8 @@ public function endTest(\PHPUnit\Framework\Test $test, float $time) : void $status = 'Skipped'; } elseif ($this->testStatus == \PHPUnit\Runner\BaseTestRunner::STATUS_INCOMPLETE) { $status = 'Incomplete'; + } elseif ($this->testStatus == \PHPUnit\Runner\BaseTestRunner::STATUS_RISKY) { + $status = 'Useless'; } elseif ($this->testStatus == \PHPUnit\Runner\BaseTestRunner::STATUS_ERROR) { $status = 'ERROR'; } else { diff --git a/src/ResultPrinter/template/scenarios.html.dist b/src/ResultPrinter/template/scenarios.html.dist index 0684c50..fedb76d 100644 --- a/src/ResultPrinter/template/scenarios.html.dist +++ b/src/ResultPrinter/template/scenarios.html.dist @@ -96,6 +96,7 @@ td.scenarioFailed { color: red } .scenarioSkipped { color: teal; } .scenarioIncomplete { color: gray; } + .scenarioUseless { color: orange; } .scenarioStepsTable { margin-left: 10px; display: none; color: #333; } #stepContainerSummary { @@ -213,6 +214,7 @@
  • {failedScenarios}
  • S {skippedScenarios}
  • I {incompleteScenarios}
  • +
  • U {uselessScenarios}
  • {header} @@ -240,6 +242,10 @@ Incomplete scenarios: {incompleteScenarios} + + Useless scenarios: + {uselessScenarios} +
    From 8e8d94232d18eae060c6da7f1888efe0124ec493 Mon Sep 17 00:00:00 2001 From: Gintautas Miselis Date: Mon, 16 May 2022 09:09:06 +0300 Subject: [PATCH 2/4] Fix test summary output of --report --- src/ResultPrinter/Report.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ResultPrinter/Report.php b/src/ResultPrinter/Report.php index 5aef95d..d1fa865 100644 --- a/src/ResultPrinter/Report.php +++ b/src/ResultPrinter/Report.php @@ -45,18 +45,19 @@ public function endTest(\PHPUnit\Framework\Test $test, float $time) : void protected function endRun() : void { - $this->write("\nCodeception Results\n"); - $this->write(sprintf( - "Successful: %s. Failed: %s. Incomplete: %s. Skipped: %s", - $this->successful, - $this->failed, - $this->skipped, - $this->incomplete - ) . "\n"); } public function printResult(\PHPUnit\Framework\TestResult $result): void { + $this->write("\nCodeception Results\n"); + $this->write(sprintf( + "Successful: %d. Failed: %d. Incomplete: %d. Skipped: %d. Useless: %d", + $this->successful, + $this->failed, + $this->skipped, + $this->incomplete, + $this->risky, + ) . "\n"); } public function write(string $buffer) : void From d0bb522a8010ddc29da610fccbbc0fc9b11a6022 Mon Sep 17 00:00:00 2001 From: Gintautas Miselis Date: Thu, 19 May 2022 20:59:06 +0300 Subject: [PATCH 3/4] Test against Codeception 4.2 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e097af8..9af523b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: php: [7.3, 7.4, 8.0] env: - CODECEPTION_VERSION: '4.1.x-dev' + CODECEPTION_VERSION: 'dev-4.2-backport-useless-test-event as 4.2.0' steps: - name: Checkout code From ff7f0f77a3e7bd274a77c579ff7519a38f96476c Mon Sep 17 00:00:00 2001 From: Gintautas Miselis Date: Thu, 19 May 2022 21:08:19 +0300 Subject: [PATCH 4/4] CI: Install modules compatible with Codeception 4.2 --- RoboFile.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/RoboFile.php b/RoboFile.php index efa9ea3..0a0fcb1 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -13,11 +13,11 @@ public function prepareDependencies() $config['name'] = 'codeception/phpunit-wrapper-test'; $config['require-dev']['codeception/codeception'] = getenv('CODECEPTION_VERSION'); - $config['require-dev']['codeception/module-asserts'] = '*'; - $config['require-dev']['codeception/module-cli'] = '*'; - $config['require-dev']['codeception/module-db'] = '*'; - $config['require-dev']['codeception/module-filesystem'] = '*'; - $config['require-dev']['codeception/module-phpbrowser'] = '*'; + $config['require-dev']['codeception/module-asserts'] = '^1.0 | ^2.0'; + $config['require-dev']['codeception/module-cli'] = '^1.0 | ^2.0'; + $config['require-dev']['codeception/module-db'] = '^1.0 | ^2.0'; + $config['require-dev']['codeception/module-filesystem'] = '^1.0 | ^2.0'; + $config['require-dev']['codeception/module-phpbrowser'] = '^1.0.3 | ^2.0.3'; $config['require-dev']['codeception/util-universalframework'] = '*'; $config['replace'] = ['codeception/phpunit-wrapper' => '*'];