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:
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?
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?
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
I 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.
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.
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.
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:inexecute_scenario’
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 W.
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’