title: Capturing and logging cucumber test results
body: <p>I'm adding logging to a test suite. It uses Ruby, Cucumber and Rspec to run. I've already set up an env.rb to log each test and can capture Scenarios and Steps and drop them into the logger but I am at a loss how to grab the actual results. </p>
  
  <p>Each test run will put something like</p>
  
  <pre><code>    1 scenario (1 passed)
      27 steps (27 passed)
      0m0.176s
  </code></pre>
  
  <p>into the console.</p>
  
  <p>I know I can grab feature name, scenario name, tags and steps using the Before do |scenario| below but I cannot find anyway of accessing the results. </p>
  
  <pre><code>$logger.level = :info
  $logger.add_appenders \
  Logging.appenders.stdout,
  Logging.appenders.file("logging/#{Time.now.strftime("%m-%d-%Y--%H:%M")}.log")
  user = `id -un` #Mac specific, sorry windows users
  user.delete!("\n")
  $logger.debug "Test run by #{user} on #{Time.now.strftime("%m/%d/%Y")}"
  
  Before do |scenario|
    @feature_name = scenario.feature.name
    @scenario_name = scenario.name
    @scenario_tags = scenario.source_tag_names
    $logger.info "FEATURE: #{@feature_name}"
    $logger.info "SCENARIO: #{@scenario_name}"
    $step_index = 0
    $stop_count = scenario.test_steps.count
    @scenario = scenario
  end
  
  AfterStep do |step|
    if $step_index &lt; $stop_count
      $logger.info "#{@scenario.test_steps[$step_index].text}\n"
    end
    $step_index += 2
  end
  </code></pre>
  
  <p>It needs to output to a .log which is why I've so far avoided the html report builders.</p>