Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit 4c622d0

Browse files
authored
Merge pull request #100 from Codeception/9.0-test.useless-event
Backport test.useless event from Codeception 5
2 parents 7d6b1a5 + ff7f0f7 commit 4c622d0

File tree

6 files changed

+27
-15
lines changed

6 files changed

+27
-15
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
php: [7.3, 7.4, 8.0]
1212

1313
env:
14-
CODECEPTION_VERSION: '4.1.x-dev'
14+
CODECEPTION_VERSION: 'dev-4.2-backport-useless-test-event as 4.2.0'
1515

1616
steps:
1717
- name: Checkout code

RoboFile.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ public function prepareDependencies()
1313

1414
$config['name'] = 'codeception/phpunit-wrapper-test';
1515
$config['require-dev']['codeception/codeception'] = getenv('CODECEPTION_VERSION');
16-
$config['require-dev']['codeception/module-asserts'] = '*';
17-
$config['require-dev']['codeception/module-cli'] = '*';
18-
$config['require-dev']['codeception/module-db'] = '*';
19-
$config['require-dev']['codeception/module-filesystem'] = '*';
20-
$config['require-dev']['codeception/module-phpbrowser'] = '*';
16+
$config['require-dev']['codeception/module-asserts'] = '^1.0 | ^2.0';
17+
$config['require-dev']['codeception/module-cli'] = '^1.0 | ^2.0';
18+
$config['require-dev']['codeception/module-db'] = '^1.0 | ^2.0';
19+
$config['require-dev']['codeception/module-filesystem'] = '^1.0 | ^2.0';
20+
$config['require-dev']['codeception/module-phpbrowser'] = '^1.0.3 | ^2.0.3';
2121
$config['require-dev']['codeception/util-universalframework'] = '*';
2222
$config['replace'] = ['codeception/phpunit-wrapper' => '*'];
2323

src/Listener.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public function __construct(EventDispatcher $dispatcher)
3737
*/
3838
public function addRiskyTest(\PHPUnit\Framework\Test $test, \Throwable $e, float $time) : void
3939
{
40+
$this->unsuccessfulTests[] = spl_object_hash($test);
41+
$this->fire('test.useless', new FailEvent($test, $time, $e));
4042
}
4143

4244
public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\AssertionFailedError $e, float $time) : void

src/ResultPrinter/HTML.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ protected function endRun():void
222222
'successfulScenarios' => $this->successful,
223223
'failedScenarios' => $this->failed,
224224
'skippedScenarios' => $this->skipped,
225-
'incompleteScenarios' => $this->incomplete
225+
'incompleteScenarios' => $this->incomplete,
226+
'uselessScenarios' => $this->risky,
226227
]
227228
);
228229

src/ResultPrinter/Report.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public function endTest(\PHPUnit\Framework\Test $test, float $time) : void
2626
$status = 'Skipped';
2727
} elseif ($this->testStatus == \PHPUnit\Runner\BaseTestRunner::STATUS_INCOMPLETE) {
2828
$status = 'Incomplete';
29+
} elseif ($this->testStatus == \PHPUnit\Runner\BaseTestRunner::STATUS_RISKY) {
30+
$status = 'Useless';
2931
} elseif ($this->testStatus == \PHPUnit\Runner\BaseTestRunner::STATUS_ERROR) {
3032
$status = 'ERROR';
3133
} else {
@@ -43,18 +45,19 @@ public function endTest(\PHPUnit\Framework\Test $test, float $time) : void
4345

4446
protected function endRun() : void
4547
{
46-
$this->write("\nCodeception Results\n");
47-
$this->write(sprintf(
48-
"Successful: %s. Failed: %s. Incomplete: %s. Skipped: %s",
49-
$this->successful,
50-
$this->failed,
51-
$this->skipped,
52-
$this->incomplete
53-
) . "\n");
5448
}
5549

5650
public function printResult(\PHPUnit\Framework\TestResult $result): void
5751
{
52+
$this->write("\nCodeception Results\n");
53+
$this->write(sprintf(
54+
"Successful: %d. Failed: %d. Incomplete: %d. Skipped: %d. Useless: %d",
55+
$this->successful,
56+
$this->failed,
57+
$this->skipped,
58+
$this->incomplete,
59+
$this->risky,
60+
) . "\n");
5861
}
5962

6063
public function write(string $buffer) : void

src/ResultPrinter/template/scenarios.html.dist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
td.scenarioFailed { color: red }
9797
.scenarioSkipped { color: teal; }
9898
.scenarioIncomplete { color: gray; }
99+
.scenarioUseless { color: orange; }
99100
.scenarioStepsTable { margin-left: 10px; display: none; color: #333; }
100101

101102
#stepContainerSummary {
@@ -213,6 +214,7 @@
213214
<li> <a href="#" title="Failed" onClick="toggleScenarios('scenarioFailed', this.parentElement)"><strong>✗</strong> {failedScenarios}</a></li>
214215
<li> <a href="#" title="Skipped" onClick="toggleScenarios('scenarioSkipped', this.parentElement)"><strong>S</strong> {skippedScenarios}</a></li>
215216
<li> <a href="#" title="Incomplete" onClick="toggleScenarios('scenarioIncomplete', this.parentElement)"><strong>I</strong> {incompleteScenarios}</a></li>
217+
<li> <a href="#" title="Useless" onClick="toggleScenarios('scenarioUseless', this.parentElement)"><strong>U</strong> {uselessScenarios}</a></li>
216218
</ul>
217219
<div class="layout">
218220
{header}
@@ -240,6 +242,10 @@
240242
<td class="scenarioIncomplete">Incomplete scenarios:</td>
241243
<td class="scenarioIncompleteValue"><strong>{incompleteScenarios}</strong></td>
242244
</tr>
245+
<tr>
246+
<td class="scenarioUseless">Useless scenarios:</td>
247+
<td class="scenarioUselessValue"><strong>{uselessScenarios}</strong></td>
248+
</tr>
243249
</table>
244250
</div>
245251
</td>

0 commit comments

Comments
 (0)