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

Patrick
  • 3,302
  • 4
  • 28
  • 47
  • 1
    I would try setting a step hook, and modifying the Step object. The step should contain a property with the text. http://docs.behat.org/guides/3.hooks.html#step-hooks – gontrollez Nov 20 '13 at 23:50
  • @gontrollez 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 code – Eduard Sukharev Sep 14 '15 at 14:14

2 Answers2

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

pscheit
  • 2,882
  • 27
  • 29
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.

Daniel
  • 940
  • 6
  • 12