[cucumber, jruby] Same steps are being added multiple times?

Hi all,

I’m not quite sure I understand how env.rb is loaded in the
cucumber/jruby
world. I have
a directory structure like this:

stories/fulfillment_status_tracking
stories/fulfillment_status_tracking/main_success.feature
stories/fulfillment_status_tracking/test.feature
stories/regular_billme_single_title_subscription
stories/regular_billme_single_title_subscription/form_validation.feature
stories/regular_billme_single_title_subscription/main_success.feature
stories/support
stories/support/env.rb

My env.rb file simply loads my Java step class and adds it, here’s what
it
looks like:

----------- env.rb -----------

require ‘cucumber/java’
import ‘com.timeinc.ecommerce.storytests.cucumber.NavigationSteps’

register_steps(NavigationSteps)
SeleniumController.markStepsLoaded()


but when I run my tests with: jruby -S cucumber -r
stories/support/env.rb

I am getting Ambiguous match of my steps - but I only have a single
class of
steps, NavigationSteps.

any ideas what’s going on?

John G. wrote:

but when I run my tests with: jruby -S cucumber -r
stories/support/env.rb

I am getting Ambiguous match of my steps - but I only have a single
class of steps, NavigationSteps.

any ideas what’s going on?

You have two (or more) step matchers that match a single clause in a
scenario. The error message usually tells you exactly which steps in
which files collide, for the MRI anyway

so I’m still stumped… how do I tell keep cucumber from loading the
SAME
steps more than once when I run multiple scenarios? I can’t be the only
person to experience this… I must be doing something wrong. I’m
loading
step classes in my env.rb file. When I add steps in cucumber/jruby
using
the register_steps() method, my test is acting like the step classes is
getting added again for each scenario?

thanks for any help,

John

I understand how this happens when I really do have ambiguous steps,
but
in my simple case, I don’t. I only have a single class which contains
steps
(attached below). I can run a single scenario just fin, but when I try
to
run multiple scenarios in one run, I get Ambiguous step errors. It’s
like
the steps are getting added again before each scenario runs - I’ve got
to be
missing something really basic here.

thanks in advance, John

PS: Here’s the one, and only one, step class that I’m using
(implementation
removed for shortness):

package com.timeinc.ecommerce.storytests.cucumber;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Test;
import
org.springframework.context.support.ClassPathXmlApplicationContext;

import com.thoughtworks.selenium.Selenium;
import com.timeinc.ecommerce.KickOffFulfillment;
import com.timeinc.ecommerce.domain.FulfillmentTransaction;
import com.timeinc.ecommerce.domain.Order;
import com.timeinc.ecommerce.domain.PersistenceService;
import com.timeinc.ecommerce.storytests.StoryTestProperties;
import com.timeinc.ecommerce.storytests.checkers.OrderChecker;
import com.timeinc.ecommerce.storytests.selenium.Page;
import com.timeinc.ecommerce.storytests.selenium.ReceiptPage;
import com.timeinc.ecommerce.storytests.selenium.SeleniumController;

import cucumber.Given;
import cucumber.Table;
import cucumber.Then;
import cucumber.When;

public class NavigationSteps {

@Given(“the microsite with”)
public void givenTheMicrosite(Table table) {
}

@When(“I navigate to the microsite”)
public void whenTheUserNavigatesToTheMicrosite() {
}

@When(“I submit the form with”)
}

@Then(“I see a receipt page”)
public void theUserIsPresentedWithAReceiptPage() {
}

@Then(“a new order is created with”)
public void aNewOrderIsCreatedWith(Table table) {
}

@Then(“the following error messages are displayed”)
public void theFollowingErrorsShouldBeDisplayed(Table table) {
Page.ensureErrorsAreDisplayed(selenium, table);
}

@When(“fulfillment runs”)
public void fulfillmentRuns() throws Exception {
}

@Given(“an order exists in the system”)
public void anOrderExistsInTheSystem() {
}

@When(“the user navigates to the status tracking page for the order”)
public void navigatesToStatusTrackingPage() {
}

@Then(“the transaction is displayed as succeeded”)
public void theTransactionIsDisplayedAsSucceeded() {
}

}

Is there a reason that you are using import instead of require? I can’t
find any documentation on import to back up my memory, but I thought
that
require keeps track so that it can ignore if you require the same thing
twice, but that import does not try to keep you from importing the same
thing twice. I would recommend changing import to require and see what
happens.

                                            /\/\ark

From: [email protected]
[mailto:[email protected]] On Behalf Of John G.
Sent: Friday, April 10, 2009 10:29 AM
To: [email protected]
Subject: [rspec-users] [cucumber,jruby] Same steps are being added
multiple
times?

so I’m still stumped… how do I tell keep cucumber from loading the
SAME
steps more than once when I run multiple scenarios? I can’t be the only
person to experience this… I must be doing something wrong. I’m
loading
step classes in my env.rb file. When I add steps in cucumber/jruby
using
the register_steps() method, my test is acting like the step classes is
getting added again for each scenario?

thanks for any help,

John

On Thu, Apr 9, 2009 at 2:19 PM, John G. [email protected]
wrote:

Hi all,

I’m not quite sure I understand how env.rb is loaded in the
cucumber/jruby
world. I have
a directory structure like this:

stories/fulfillment_status_tracking
stories/fulfillment_status_tracking/main_success.feature
stories/fulfillment_status_tracking/test.feature
stories/regular_billme_single_title_subscription
stories/regular_billme_single_title_subscription/form_validation.feature
stories/regular_billme_single_title_subscription/main_success.feature
stories/support
stories/support/env.rb

My env.rb file simply loads my Java step class and adds it, here’s what
it
looks like:

----------- env.rb -----------

require ‘cucumber/java’
import ‘com.timeinc.ecommerce.storytests.cucumber.NavigationSteps’

register_steps(NavigationSteps)
SeleniumController.markStepsLoaded()


but when I run my tests with: jruby -S cucumber -r
stories/support/env.rb

I am getting Ambiguous match of my steps - but I only have a single
class of
steps, NavigationSteps.

any ideas what’s going on?


John G. RADSoft / Better Software Faster
[email protected] Lean/Agile/XP/Scrum Coaching and
Training
http://www.radsoft.com Ruby on Rails and Java Solutions


John G. RADSoft / Better Software Faster
[email protected] Lean/Agile/XP/Scrum Coaching and
Training
http://www.radsoft.com Ruby on Rails and Java Solutions

__________ Information from ESET NOD32 Antivirus, version of virus
signature
database 3999 (20090410) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

OK, I’ll reproduce in a simple example and create a ticket…

On Fri, Apr 10, 2009 at 5:29 PM, John G. [email protected]
wrote:

so I’m still stumped… how do I tell keep cucumber from loading the SAME
steps more than once when I run multiple scenarios? I can’t be the only
person to experience this… I must be doing something wrong. I’m loading
step classes in my env.rb file. When I add steps in cucumber/jruby using
the register_steps() method, my test is acting like the step classes is
getting added again for each scenario?

You may have run into a bug with cucumber_java. It hasn’t undergone the
same
scrutiny as cucumber yet.

Can you modify the simple example in cucumber_java so that this is
reproducible for others? Then create a ticket where you describe the
exact
steps to reproduce the error.

Cheers,
Aslak

On Tue, Apr 14, 2009 at 12:08 AM, John G. [email protected]
wrote:

OK, I’ll reproduce in a simple example and create a ticket…

Excellent - I’ll get to it ASAP

Aslak Hellesøy wrote:

On Tue, Apr 14, 2009 at 12:08 AM, John G. [email protected]
wrote:

OK, I’ll reproduce in a simple example and create a ticket…

Excellent - I’ll get to it ASAP

I am also having the same issue with cucumber-java.

please refer - Ambigous error while running cucumber features - RSpec - Ruby-Forum

With cucumber-java , it seems that we would be able to run only one
feature file and one scenario in that file.

Is there any way by which we can execute multiple feature files that
will invoke seperate scenarios?

Thanks,
Neema

please refer - Ambigous error while running cucumber features - RSpec - Ruby-Forum

With cucumber-java , it seems that we would be able to run only one
feature file and one scenario in that file.

Sounds like a bug then.

Is there any way by which we can execute multiple feature files that
will invoke seperate scenarios?

Someone fixes the bug :wink:

Aslak

On Sat, Apr 18, 2009 at 8:23 AM, Neema Cheriyath
[email protected]wrote:

Aslak Hellesøy wrote:

On Tue, Apr 14, 2009 at 12:08 AM, John G. [email protected]
wrote:

OK, I’ll reproduce in a simple example and create a ticket…

Excellent - I’ll get to it ASAP

I never got a ticket from any of you, but I have committed a fix:
http://github.com/aslakhellesoy/cucumber_java/commit/5f8f31b3d2b34050a93e27990ed25ce9274f49ac

So it will be in the next release.

Aslak