Closed thekid closed 6 years ago
Exceptions from @beforeClass methods skip all tests if they fail. In certain situations, if may be better to fail them.
@beforeClass
This can be done by throwing a PrerequisitesFailedError (instead of a PrerequisitesNotMetError) from these methods.
PrerequisitesFailedError
PrerequisitesNotMetError
use unittest\{TestCase, PrerequisitesFailedError}; class ExampleTest extends TestCase { #[@beforeClass] public static function startServer() { $server= ...; try { $server->start(); } catch (CouldNotStartServer $e) { throw new PrerequisitesFailedError('Could not start server', $e, [$server]); } } // ... }
Released in https://github.com/xp-framework/unittest/releases/tag/v9.6.0
Exceptions from
@beforeClass
methods skip all tests if they fail. In certain situations, if may be better to fail them.This can be done by throwing a
PrerequisitesFailedError
(instead of aPrerequisitesNotMetError
) from these methods.Example