refactor: use fixtures for hook failure tests#1688
refactor: use fixtures for hook failure tests#1688carlos-granados merged 1 commit intoBehat:masterfrom
Conversation
| Scenario: First scenario | ||
| When I have a simple step | ||
| """ | ||
| Given I initialise the working directory from the "HookFailures" fixtures folder |
There was a problem hiding this comment.
Use the fixtures from the "HookFailures" folder
| And I provide the following options for all behat invocations: | ||
| | option | value | | ||
| | --no-colors | | | ||
| | --format | json | |
There was a problem hiding this comment.
Define the output format for all tests
| When I run "behat --no-colors --format=json --out=beforesuite.json" | ||
| When I run behat with the following additional options: | ||
| | option | value | | ||
| | --profile | beforeSuite | |
There was a problem hiding this comment.
We use the profile that matches what we want to test
There was a problem hiding this comment.
Testing this with annotations does not provide any real value. We already test that hook annotations are processed in other tests and the hook failures tests are about the output when one of these failures happen
| Scenario: First scenario | ||
| When I have a simple step | ||
| """ | ||
| Given I initialise the working directory from the "HookFailures" fixtures folder |
There was a problem hiding this comment.
The tests use the same fixture folder for all formatters
| { | ||
| private static bool $thrown = false; | ||
|
|
||
| protected static function throwFailure(string $message): void |
There was a problem hiding this comment.
We implement a function that only throws an exception the first time it is called, this allows us to use this with several suites, features, scenarios or steps
acoulton
left a comment
There was a problem hiding this comment.
Much cleaner, thanks @carlos-granados
Updates the hook failures tests to use fixtures instead of files created on the fly. Uses a single fixture folder for all hook failures tests. Removes hook failure tests for annotations