codegram / spinach

Spinach is a BDD framework on top of Gherkin.
codegram.github.com/spinach
MIT License
580 stars 69 forks source link

Show line number of failed scenario #172

Open cirosantilli opened 9 years ago

cirosantilli commented 9 years ago

It would be cool to see it at least on the Errors summary, something like:

Error summary:
  Failures (1)
    A :: B :: C (line 123)

so I can easily run just the failing test next with spinach test.spinach:123

aackerman commented 9 years ago

It would be even better to do as cucumber as rspec and output the exact command to re-run a failing test to allow for simple copy/paste.

javierav commented 9 years ago

@cirosantilli @aackerman You can easily create your own reporter to show the required info. For example, I recently created a reporter that writes failing scenarios in a txt file to rerun them later: https://github.com/arandaio/spinach-rerun-reporter :wink:

alkuzad commented 8 years ago

hack for that (append to env)

module Spinach
  class Reporter
    # This module handles Stdout's reporter error reporting capabilities.
    module Reporting
      def summarized_error(error)
        feature, scenario, step, exception = error
        summary = "    #{feature.name} :: #{scenario.name} :: #{full_step step} (#{feature.instance_variable_get('@filename')}:#{scenario.line})"
        if exception.kind_of?(Spinach::StepNotDefinedException)
          summary.red
        elsif exception.kind_of?(Spinach::StepPendingException)
          summary += "\n      Reason: '#{exception.reason}'\n"
          summary.yellow
        else
          summary.red
        end
      end
    end
  end
end
mileslane commented 6 years ago

We found that the approach shown above no longer works with spinach 0.10.1. Support for "scenario.line" has been removed and replaced with "scenario.lines". Unfortunately, this spits out all the line numbers, not just the one for the failing test. A way to get the old behavior back would be appreciated.