Getting specific error info from Cucumber?

Hi all… I have just gotten started with Cucumber and excited about
it.
But am hitting a problem where I have scenarios failing but the output
seems
almost useless - all it does is tell me which scenarios failed but not
where
in the scenario it failed. How does one go about figuring out where
things
are going wrong? Is there a verbose option?

For example on this failing (and very simple) scenario (which I can not
remove enough steps to get it to pass):

Feature: Login logout of system

Scenario: Login
When I am on the login page
Then I should see “Lender Login”

When I ‘rake cucumber’ it fails, I have no idea if the problem is
syntax,
routes, something with capybara, data (well not in this case), or just
that
my app does not work. I know I can go to a browser and get this page to
load
so I know it is not the latter.

I am not concerned with this specific example per se but to any hints as
to
a working strategy to troubleshoot scenarios under Cucumber and be able
to
move past failures.

Thanks,

David

David K. wrote:

Hi all… I have just gotten started with Cucumber and excited about
it.
But am hitting a problem where I have scenarios failing but the output
seems
almost useless - all it does is tell me which scenarios failed but not
where
in the scenario it failed. How does one go about figuring out where
things
are going wrong? Is there a verbose option?

You know, if you’re going to complain about the output, the least you
could do is show us the output you’re getting… :slight_smile:

For example on this failing (and very simple) scenario (which I can not
remove enough steps to get it to pass):

That suggests a Cucumber setup issue.

Feature: Login logout of system

Scenario: Login
When I am on the login page
Then I should see “Lender Login”

When I ‘rake cucumber’ it fails,

Fails how? What do you see?

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sent from my iPhone

You know, if you’re going to complain about the output, the least you
could do is show us the output you’re getting… :slight_smile:

Here goes:

/Users/DK/.rvm/rubies/ruby-1.8.7-p174/bin/ruby -I
“/Users/DK/.rvm/gems/ruby-1.8.7-p174/gems/cucumber-0.8.5/lib:lib”
“/Users/DK/.rvm/gems/ruby-1.8.7-p174/gems/cucumber-0.8.5/bin/cucumber”
–profile default
Using the default profile…
F-----F–

Failing Scenarios:
cucumber features/create_comparison.feature:6 # Scenario: Comparisons
List
cucumber features/login_logout.feature:3 # Scenario: Login

2 scenarios (2 failed)
7 steps (7 skipped)
0m0.042s
rake aborted!
Command failed with status (1):
[/Users/DK/.rvm/rubies/ruby-1.8.7-p174/bin/…]

(See full trace by running task with --trace)
DKMac:creditcompare DK$

On Wed, Sep 15, 2010 at 5:06 PM, Marnen Laibow-Koser

David K. wrote:

You know, if you’re going to complain about the output, the least you
could do is show us the output you’re getting… :slight_smile:

Here goes:

/Users/DK/.rvm/rubies/ruby-1.8.7-p174/bin/ruby -I
“/Users/DK/.rvm/gems/ruby-1.8.7-p174/gems/cucumber-0.8.5/lib:lib”
“/Users/DK/.rvm/gems/ruby-1.8.7-p174/gems/cucumber-0.8.5/bin/cucumber”
–profile default
Using the default profile…
F-----F–

Failing Scenarios:
cucumber features/create_comparison.feature:6 # Scenario: Comparisons
List
cucumber features/login_logout.feature:3 # Scenario: Login

2 scenarios (2 failed)
7 steps (7 skipped)
0m0.042s
rake aborted!
Command failed with status (1):
[/Users/DK/.rvm/rubies/ruby-1.8.7-p174/bin/…]

That does look rather terse – but notice that all your steps are
showing up as skipped. I’d say you’ve got a configuration issue. Check
your cucumber setup.

(See full trace by running task with --trace)
DKMac:creditcompare DK$

On Wed, Sep 15, 2010 at 5:06 PM, Marnen Laibow-Koser

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sent from my iPhone

That does look rather terse – but notice that all your steps are
showing up as skipped. I’d say you’ve got a configuration issue. Check
your cucumber setup.

So it was a configuration error, having to do with my discovery that the
config/environment/cucumber.rb environment which was missing some app
specific constants, which in turn was causing my loading of fixtures to
fail
(albeit unreported).

Now another issue: I have my test::unit fixtures loading and confirmed
(this
is a legacy app). However they can not seem to be accessed from the
code.
This is what is in env.rb to load them:

Before do
Fixtures.reset_cache
fixtures_folder = File.join(RAILS_ROOT, ‘test’, ‘fixtures’)
fixtures = Dir[File.join(fixtures_folder, ‘*.yml’)].map {|f|
File.basename(f, ‘.yml’) }
Fixtures.create_fixtures(fixtures_folder, fixtures)
end

Then for example, in the cucumber step below, when I set the debugger, I
can
find, the specific users fixture through
Fixtures.all_loaded_fixtures[“users”][“sysadmin_user_one”]

But I can not get at its data (maybe you can tell me how to get at a
class
attribute inside a fixture object):

(rdb:1) Fixtures.all_loaded_fixtures[“users”][“sysadmin_user_one”]
#<Fixture:0x47776a4 @model_class=User(id: integer, login: string,
first_name: string, last_name: string, email: string, role_id: integer,
hashed_password: string, salt: string, created_at: datetime, updated_at:
datetime, enabled: boolean, account_id: integer, email_upon_upload:
boolean), @fixture={“salt”=>987654, “created_at”=>“2010-09-16
18:13:09”,
“updated_at”=>“2010-09-16 18:13:09”, “role_id”=>1033329129,
“hashed_password”=>“501d40d3a18d954855335c06bd56d47f8f5d4adc”,
“id”=>1067249891, “enabled”=>true, “last_name”=>“One”,
“login”=>“sysadminone”, “email”=>“[email protected]”,
“first_name”=>“Sysadmin”},

And using “users(:user_name)” as I would in Test::Unit does not work -
this
is where the step is failing.

I hope this is not as disgusting as I am making it… am I fighting the
universe (or in this case Cucumber::Rails::World) on this?

Given /^I am logged in as a sysadmin user$/ do
user = users(:sysadmin_user_one)
visit(’/login’)
fill_in(‘login’, user.login)
fill_in(‘password’, ‘password1’)
click_button(‘Log in’)
I should see ‘Welcome Sysadmin One’
end

Thanks,

David

On Wed, Sep 15, 2010 at 7:11 PM, Marnen Laibow-Koser

David K. wrote:

That does look rather terse – but notice that all your steps are
showing up as skipped. I’d say you’ve got a configuration issue. Check
your cucumber setup.

So it was a configuration error, having to do with my discovery that the
config/environment/cucumber.rb environment which was missing some app
specific constants, which in turn was causing my loading of fixtures to
fail
(albeit unreported).

Now another issue: I have my test::unit fixtures loading and confirmed
(this
is a legacy app). However they can not seem to be accessed from the
code.

Good. You shouldn’t be using fixtures in Cucumber – or indeed at all.
The feature, as implemented in Rails, is broken and should be avoided at
all costs.

Use factories instead (either Machinist or Factory Girl will work). For
integration of factories and Cucumber, Pickle works well.

[…]

I hope this is not as disgusting as I am making it… am I fighting the
universe (or in this case Cucumber::Rails::World) on this?

Given /^I am logged in as a sysadmin user$/ do
user = users(:sysadmin_user_one)
visit(’/login’)
fill_in(‘login’, user.login)
fill_in(‘password’, ‘password1’)
click_button(‘Log in’)
I should see ‘Welcome Sysadmin One’
end

That step looks good, except for the use of fixtures.

Thanks,

David

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

On Thu, Sep 16, 2010 at 2:23 PM, Marnen Laibow-Koser
[email protected] wrote:

Good. You shouldn’t be using fixtures in Cucumber – or indeed at all.
The feature, as implemented in Rails, is broken and should be avoided at
all costs.

Fixtures work great for me.

But if the sky is falling for you…


Greg D.
destiney.com | gregdonald.com

On Thu, Sep 16, 2010 at 2:26 PM, Greg D. [email protected] wrote:
Fixtures work great for me.

Greg, so you are able to load and use fixtures on cucumber on
Rails3/1.9.2?
Would you mind sharing how you load them in config and access them?

David

Greg D. wrote:

On Thu, Sep 16, 2010 at 2:23 PM, Marnen Laibow-Koser
[email protected] wrote:

Good. �You shouldn’t be using fixtures in Cucumber – or indeed at all.
The feature, as implemented in Rails, is broken and should be avoided at
all costs.

Fixtures work great for me.

Have you tried factories? They work even better.

But if the sky is falling for you…

I guess ignorance is bliss.


Greg D.
destiney.com | gregdonald.com

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sent from my iPhone

Never mind. I just found this:

http://wiki.github.com/aslakhellesoy/cucumber/fixtures
Which states:

…you can access your fixture data from the database using
Model.find.
Example to find the first User model you’d use User.find(:first).

So I was just trying to use the Test::Unit way – users{:sysadminone),
vs
User.find_by_login(‘sysadminone’) – and that was the problem. Works
right
on.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs