Patrick
Patrick

Reputation: 3440

Adding information to Behat output from custom context code

I am trying to determine how I would add additional information to Behat's output (pretty, html, junit, etc) so I can have more contextual information for the test purposes.

Specifically I have some unique data that gets generated during some of the tests. I have been echoing it to the console. But that never ends up in any of the files that are generated in reports. I would like this information that I have been outputting to the console to end up in the reports. How would I do that from my FeatureContext.php custom steps?

Thanks, Patrick

Upvotes: 10

Views: 1614

Answers (2)

pscheit
pscheit

Reputation: 2981

If using behat 3.x just print, var_dump, var_export, etc in your code. It will be caught and printed from behat

database-setup-output

Reference: https://github.com/Behat/Behat/issues/347

Upvotes: 1

Daniel
Daniel

Reputation: 1085

Following your current "solution" you can redirect the output of console to another file. This way the original format is kept clean and valid (e.g. jUnit) and you can parse and keep further information separate.

How to redirect the output depends on you OS. E.g. you can follow http://wiki.bash-hackers.org/syntax/redirection for Bash shell on *nix Systems.

Upvotes: 0

Related Questions