mirror of
https://github.com/pestphp/pest.git
synced 2026-09-05 06:13:35 +02:00
fix(tia): treat a test skipped from a hook as finished (#1863)
This commit is contained in:
committed by
GitHub
parent
a8d4770c0b
commit
2e58918201
@@ -117,7 +117,7 @@ final class ResultCollector
|
|||||||
|
|
||||||
public function hasUnfinishedTest(): bool
|
public function hasUnfinishedTest(): bool
|
||||||
{
|
{
|
||||||
return $this->currentTestId !== null;
|
return $this->currentTestId !== null && ! isset($this->results[$this->currentTestId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function recordAssertions(string $testId, int $assertions): void
|
public function recordAssertions(string $testId, int $assertions): void
|
||||||
|
|||||||
@@ -33,6 +33,34 @@ test('a complete run prunes a deleted test', function (array $arguments): void {
|
|||||||
->and($delta->structureMoved())->toBeFalse($delta->summary());
|
->and($delta->structureMoved())->toBeFalse($delta->summary());
|
||||||
})->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows();
|
})->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows();
|
||||||
|
|
||||||
|
test('a complete run stays complete when the last test is skipped from a hook', function (array $arguments): void {
|
||||||
|
$project = Project::make('master');
|
||||||
|
$project->seed('master');
|
||||||
|
|
||||||
|
$project->write('tests/Unit/GreeterTest.php', <<<'PHP'
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Fixture\App\Greeter;
|
||||||
|
|
||||||
|
beforeEach(function (): void {
|
||||||
|
test()->markTestSkipped('not today');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('greets a person', function (): void {
|
||||||
|
expect((new Greeter)->greet('Nuno'))->toBe('Hello, Nuno!');
|
||||||
|
});
|
||||||
|
PHP);
|
||||||
|
|
||||||
|
$result = $project->pest(...$arguments);
|
||||||
|
$delta = $project->delta();
|
||||||
|
|
||||||
|
expect($result->tally())->toContain('1 skipped')
|
||||||
|
->and($delta->removed())->toBe(1, $delta->summary())
|
||||||
|
->and($delta->added())->toBe(0, $delta->summary());
|
||||||
|
})->with(Project::SEQUENTIAL_AND_PARALLEL)->skipOnWindows();
|
||||||
|
|
||||||
test('a complete run records nothing for a test file the graph does not know', function (): void {
|
test('a complete run records nothing for a test file the graph does not know', function (): void {
|
||||||
$project = Project::make('master');
|
$project = Project::make('master');
|
||||||
$project->seed('master');
|
$project->seed('master');
|
||||||
|
|||||||
Reference in New Issue
Block a user