Where and how do you put custom logger statements in cucumber? I understood (more or less) how to do this in rspec in the spec_helper file but I do not know where to start with cucumber. I want to add a simple identifying text line in the log file to assist in picking through the output. Something akin to: Running Scenario: X Feature I should have this logged .... Feature This should get logged too .... Running Scenario: Y Feature This is somewhat different .... -- Posted via http://www.ruby-forum.com/.
On Mon, Nov 24, 2008 at 8:40 PM, James Byrne <lists at ruby-forum.com> wrote:> Where and how do you put custom logger statements in cucumber? I > understood (more or less) how to do this in rspec in the spec_helper > file but I do not know where to start with cucumber. >Are you using any particular framework along with Cucumber? -Like Merb or other?> > I want to add a simple identifying text line in the log file to assist > in picking through the output. Something akin to: > > Running Scenario: X > > Feature I should have this logged > .... > > Feature This should get logged too > .... > > > Running Scenario: Y > > Feature This is somewhat different > .... > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081124/7cc3a2bc/attachment.html>
aslak hellesoy wrote:> On Mon, Nov 24, 2008 at 8:40 PM, James Byrne <lists at ruby-forum.com> > wrote: > >> Where and how do you put custom logger statements in cucumber? I >> understood (more or less) how to do this in rspec in the spec_helper >> file but I do not know where to start with cucumber. >> > > Are you using any particular framework along with Cucumber? -Like Merb > or other?Rails 2.2.2 -- Posted via http://www.ruby-forum.com/.
On Mon, Nov 24, 2008 at 9:00 PM, James Byrne <lists at ruby-forum.com> wrote:> aslak hellesoy wrote: > > On Mon, Nov 24, 2008 at 8:40 PM, James Byrne <lists at ruby-forum.com> > > wrote: > > > >> Where and how do you put custom logger statements in cucumber? I > >> understood (more or less) how to do this in rspec in the spec_helper > >> file but I do not know where to start with cucumber. > >> > > > > Are you using any particular framework along with Cucumber? -Like Merb > > or other? > > Rails 2.2.2 >It depends what you want to log and when. Have you tried to put it in a Before or After block? I''m not sure exactly what you''re trying to achieve. Aslak> > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081124/ba867c9a/attachment.html>
aslak hellesoy wrote:> On Mon, Nov 24, 2008 at 9:00 PM, James Byrne <lists at ruby-forum.com> > wrote: > >> > or other? >> >> Rails 2.2.2 >> > > It depends what you want to log and when. Have you tried to put it in a > Before or After block? > > I''m not sure exactly what you''re trying to achieve. > > AslakI am looking for where in hierarchy to put a global logger command that will apply to each scenario and/or step, and probably what form the command should take. I want to provide a text delimiter within log/test.log to identify what activity takes place behind the curtains when each scenario and step is run. Something like. logger.info("Running Scenario: #{scenario}" ... logger.info(" Running Step: #{step}" ... I tried to make sense out of the discussion surrounding ticket: http://rspec.lighthouseapp.com/projects/16211/tickets/44-ability-to-teardown-failing-or-pending-scenarios-in-different-ways Truth be told, I can only dimly grasp at what is going on. It seems that the place to put something like I seek would be in features/support or features itself. I gather that before / after block only work within step files? If so then that requires each step file be modified to turn custom logging on or off, which is something I would much rather avoid. -- Posted via http://www.ruby-forum.com/.
James Byrne wrote:> logger.info("Running Scenario: #{scenario}" > ... > logger.info(" Running Step: #{step}" > ...should be: logger.info("Running Scenario: #{scenario}") and logger.info(" Running Step: #{step}") -- Posted via http://www.ruby-forum.com/.
>I gather that before / after block only work within >step files? If so then that requires each step file be modified to turn >custom logging on or off, which is something I would much rather avoid.I don''t think this is the case. Every Before/After that is in a required file is run before a scenario. So in theory you could create one Before (in for example env.rb) which would get called for all scenarios. As for steps well, that sounds a lot trickier. I cannot think of a clean way to get at that. If you want steps now in a clean way I would suggest looking at making a custom formatter. Cucumber supports multiple formatters so you could run your rails logging formatter with other formatters. Bundle this up in a --profile to save typing long command line args. The formatter knows when every scenario is executed and when every step passes/fails/skips etc. If you look at the progress formatter in cucumber it should be a good start for you. HTH, -- Joseph Wilk http://blog.josephwilk.net -- Posted via http://www.ruby-forum.com/.
Joseph Wilk wrote:> > I don''t think this is the case. Every Before/After that is in a required > file is run before a scenario. So in theory you could create one Before > (in for example env.rb) which would get called for all scenarios. >I experimented with the following code in env.rb, borrowing heavily from the discussion on ticker 44 and this is what happened: Before do |scenario| logger.info("Running Scenario: #{scenario}") end Scenario: Record Entity basic identification information # features/entities/entity.feature:12 /usr/lib/ruby/gems/1.8/gems/cucumber-0.1.9/bin/../lib/cucumber/core_ext/proc.rb:15:in `call_in'': expected 1 block argument(s), got 0 (Cucumber::ArityMismatchError) from /usr/lib/ruby/gems/1.8/gems/cucumber-0.1.9/bin/../lib/cucumber/executor.rb:91:in `execute_scenario'' -- Posted via http://www.ruby-forum.com/.
James Byrne wrote:> Joseph Wilk wrote: >> >> I don''t think this is the case. Every Before/After that is in a required >> file is run before a scenario. So in theory you could create one Before >> (in for example env.rb) which would get called for all scenarios. >> > > I experimented with the following code in env.rb, borrowing heavily from > the discussion on ticker 44 and this is what happened: > > Before do |scenario| > logger.info("Running Scenario: #{scenario}") > end >The patch that you are referring to in ticket #44 has not been merged in. So passing a block to scenario is not currently possible. -- Joseph Wilk http://blog.josephwilk.net> Scenario: Record Entity basic identification information # > features/entities/entity.feature:12 > /usr/lib/ruby/gems/1.8/gems/cucumber-0.1.9/bin/../lib/cucumber/core_ext/proc.rb:15:in > `call_in'': expected 1 block argument(s), got 0 > (Cucumber::ArityMismatchError) > from > /usr/lib/ruby/gems/1.8/gems/cucumber-0.1.9/bin/../lib/cucumber/executor.rb:91:in > `execute_scenario''-- Posted via http://www.ruby-forum.com/.
Apparently Analagous Threads
- Any plans for Before-feature or Before-all steps in Cucumber?
- [cucumber][v0.2alpha]Where could I find API docs for custom formatters?
- Cucumber Scenario Outlines Output Insufficient
- [Cucumber] after feature hook?
- cucumber features HTML output bug with more than 100 steps