Adding information to Behat output from custom context code
Asked Answered
R

2

10

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

Rademacher answered 18/11, 2013 at 17:6 Comment(2)
I would try setting a step hook, and modifying the Step object. The step should contain a property with the text. docs.behat.org/guides/3.hooks.html#step-hooksPilose
@Pilose i believe the Step object (or at least some of it's properties) are immutable once feature files are parsed and steps are actually used to run some codeCates
B
1

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

Baptlsta answered 24/8, 2017 at 7:42 Comment(0)
L
0

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.

Landlocked answered 22/12, 2015 at 15:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.