Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The cucumber --format stepdefs stack trace is too harsh and doesn't provide a solution #1285

Closed
mbigras opened this issue Mar 26, 2018 · 4 comments
Assignees

Comments

@mbigras
Copy link

mbigras commented Mar 26, 2018

Summary

Thank you for this project!

I'm having an issue when using cucumber --format stepdefs when there is a typo in my step.
The cucumber --format stepdefs stack trace is too harsh and doesn't provide guidance to a solution.
Issues #953 and #955 point out a problem with using the --format stepdefs flag but don't clarify the problem or provide a solution.

The work around solution is:

  • remove the step
  • comment out the step
  • make a stub definition of the step

Main idea

Given I first installed cucumber and aruba
And I'm not an expert at debugging Ruby applications
And I make a typo in my step
And I want to check out the avaiable step definitions to see what my typo was
When I run `cucumber --format stepdefs`
Then the command should fail
And I shouldn't be shown a 40 line Ruby stack trace
And there should be a helpful error message that looks something like:
  """
  You can't use the `--format stepdefs` flag with undefined steps!
  Implement the steps and try again.

  You can implement step definitions for undefined steps with these snippets:

  Then("the command should pass with:") do |string|
    pending # Write code here that turns the phrase above into concrete actions
  end
  """

Or, there should be a feature to just preview all the steps.
Or, the `--dry-run` switch should work.

Steps to Reproduce (for bugs)

gem install cucumber:3.1.0 aruba:0.14.5
mkdir cukular_bomb
cd cukular_bomb/
cucumber --init
cat <<'EOF' > features/support/env.rb
require 'aruba/cucumber'
EOF
cat <<'EOF' > features/helloruby.feature
Feature: Ruby's command line interface
  Scenario: Using the -e flag
    When I run `ruby -e 'print "hello world!"'`
    Then the command should pass with:
      """
      hello world!
      """
EOF
cucumber
cucumber --format stepdefs
cucumber --format stepdefs 2>&1 | awk 'END { print NR }'

Context & Motivation

Showing a user a 40 line stack trace for making a typo in the step definition is too harsh and not helpful.

Your Environment

sw_vers
ProductName:	Mac OS X
ProductVersion:	10.12.6
BuildVersion:	16G1036

gem list cucumber aruba

*** LOCAL GEMS ***

cucumber (3.1.0)
cucumber-core (3.1.0, 2.0.0)
cucumber-expressions (5.0.13)
cucumber-tag_expressions (1.1.1)
cucumber-wire (0.0.1)

*** LOCAL GEMS ***

aruba (0.14.5)

Also, there is a repo I put together that will also reproduce the error: https://github.com/mbigras/cukular_bomb

Stack trace for reference

cucumber --format stepdefs
.undefined method `step_definition' for nil:NilClass (NoMethodError)
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-3.1.0/lib/cucumber/formatter/usage.rb:41:in `on_test_step_finished'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/event_bus.rb:34:in `block in broadcast'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/event_bus.rb:34:in `each'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/event_bus.rb:34:in `broadcast'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/event_bus.rb:40:in `method_missing'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/test/runner.rb:35:in `around_hook'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/test/around_hook.rb:12:in `describe_to'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/test/case.rb:120:in `block (2 levels) in compose_around_hooks'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/test/case.rb:121:in `compose_around_hooks'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/test/case.rb:26:in `block in describe_to'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/test/runner.rb:19:in `test_case'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/test/case.rb:25:in `describe_to'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-3.1.0/lib/cucumber/filters/prepare_world.rb:12:in `test_case'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/test/case.rb:25:in `describe_to'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/filter.rb:57:in `test_case'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-3.1.0/lib/cucumber/filters/retry.rb:18:in `test_case'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/test/case.rb:25:in `describe_to'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-3.1.0/lib/cucumber/filters/quit.rb:12:in `test_case'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/test/case.rb:25:in `describe_to'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-3.1.0/lib/cucumber/filters/broadcast_test_run_started_event.rb:20:in `block in done'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-3.1.0/lib/cucumber/filters/broadcast_test_run_started_event.rb:19:in `map'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-3.1.0/lib/cucumber/filters/broadcast_test_run_started_event.rb:19:in `done'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/filter.rb:62:in `done'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/filter.rb:62:in `done'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/filter.rb:62:in `done'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/filter.rb:62:in `done'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/filter.rb:62:in `done'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/test/filters/locations_filter.rb:20:in `done'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/filter.rb:62:in `done'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/test/filters/tag_filter.rb:18:in `done'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/compiler.rb:24:in `done'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core/gherkin/parser.rb:37:in `done'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core.rb:32:in `parse'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-core-3.1.0/lib/cucumber/core.rb:21:in `compile'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-3.1.0/lib/cucumber/runtime.rb:74:in `run!'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-3.1.0/lib/cucumber/cli/main.rb:33:in `execute!'
/Users/mbigras/.gem/ruby/2.4.2/gems/cucumber-3.1.0/bin/cucumber:9:in `<top (required)>'
/Users/mbigras/.gem/ruby/2.4.2/bin/cucumber:23:in `load'
/Users/mbigras/.gem/ruby/2.4.2/bin/cucumber:23:in `<main>'
@xtrasimplicity
Copy link
Member

xtrasimplicity commented Mar 27, 2018

I'm not overly familiar with the codebase so I'm not sure of the feasibility, but I like the idea! :)

@mbigras, Would you be willing to work on a PR for this?

@xtrasimplicity
Copy link
Member

I'm working on a fix for this right now. Will submit a PR when I'm ready. :)

@xtrasimplicity
Copy link
Member

The PR to resolve this has been merged, so I'll close this off.

@lock
Copy link

lock bot commented Mar 31, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Mar 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants