diff --git a/Classes/Behavior/Features/Bootstrap/GenericCommandExecutionAndEventPublication.php b/Classes/Behavior/Features/Bootstrap/GenericCommandExecutionAndEventPublication.php index 67c91d5..8ca9633 100644 --- a/Classes/Behavior/Features/Bootstrap/GenericCommandExecutionAndEventPublication.php +++ b/Classes/Behavior/Features/Bootstrap/GenericCommandExecutionAndEventPublication.php @@ -321,6 +321,7 @@ public function theLastCommandShouldHaveThrown(string $shortExceptionName, ?int $this->lastCommandException->getMessage() )); } + $this->lastCommandException = null; } /** @@ -343,6 +344,23 @@ public function theLastCommandShouldHaveThrownTheWorkspaceRebaseFailedWith(Table } Assert::assertSame($payloadTable->getHash(), $actualComparableHash); + $this->lastCommandException = null; + } + + /** + * @AfterScenario + */ + public function ensureNoUnhandledCommandExceptions(\Behat\Behat\Hook\Scope\AfterScenarioScope $event): void + { + if ($this->lastCommandException !== null) { + Assert::fail(sprintf( + 'Last command did throw with exception which was not asserted: %s: "%s" in %s:%s', + $this->lastCommandException::class, + $this->lastCommandException->getMessage(), + $event->getFeature()->getFile(), + $event->getScenario()->getLine(), + )); + } } /**