We test so we can have increased confidence in our product that we are about to ship. We have to have it all green and passing. But sometimes when we’re lucky and have designed our tests well, they will fail and let us know that something is not working as intended.
When that time comes, we have to be prepared. The more information we can get around the failure the less time it will take to gather the facts around it. Lucky us, its easier than we think!
This is the standard failure output from one of the step definitions:
This is what we can make of it.
Interested? Go ahead and install this awesome package!
composer require genesis/behat-fail-aid --dev
Then in your behat.yml file
#behat.yml
default:
suites:
default:
contexts:
- FailAid\Context\FailureContext
extensions:
FailAid\Extension: ~
That’s it! Run your tests again to get more info around them.
You can get more out of this package by configuring more options defined in the package README. Have a look here https://github.com/forceedge01/behat-fail-aid.
Don’t forget to star the package if you like it!
Full behat.yml configuration
extensions: FailAid\Extension: screenshotDirectory: ./fail-screenshots/ screenshotMode: default # The screenshot modes, default produces a png and html produces a html version (filters applied). debugBarSelectors: # If you have a debug bar showing, you can use this to retrieve more information on failure. message: '#debugBar .message' queries: '#debugBar .queries' siteFilters: # Filters to apply on the screenshot captured, usually used to fix relative links in your webpage. '/images/': 'http://dev.environment/images/' '/js/': 'http://dev.environment/js/'