I've got some ruby tests that are calling different modules, classes where they detail what they're doing with some "puts" commands during execution.
If you run those tests in the console then you will see the output of the "puts" command in the console but if you run the tests with the option:
ruby --format html --output file.html
then all that information is lost. Is there a way to log simple string messages inside the HTML report?
I tried the following steps:
...with the following command:
...when I opened up the
results.html
file in a browser, it displayed the "Hello" message just after displaying the step. I've attached the pertinent section of the HTML output so you can see that the output fromputs
is there:What that demonstrates is that when cucumber's
puts
method is called (ie: directly from within a step) the output will be included in the html output. But if theputs
call is from somewhere else (eg: your modules) then it won't be included. You could consider moving yourputs
calls from the modules to the steps. Also, usingputs
isn't really best practice so you may want to consider removing it altogether...You can remember World in Before hook of each scenario:
Then in your support classes and modules outside world you can use puts as:
Also you can get/set Cucumber instance variables as:
I also prefer to extract those 2 methods to helpers for better visibility:
Then you can include this module where you need those methods