Background steps run even when no scenarios exist in the file

206 views
Skip to first unread message

Carl Manaster

unread,
Apr 16, 2015, 7:48:06 PM4/16/15
to calabash...@googlegroups.com
Hi,

We use tags to prevent certain scenarios from running (@manual, @wip, etc.).  Our system is configured not to run such scenarios, but we have seen that when a feature file contains only scenarios with such tags, although the scenarios themselves do not run, the background runs.  We would expect that if no runnable scenario is found in a file, the file's background is never run.


Examples:

----------------------------------------------------------------------

calabash-android run ../android/app/build/outputs/apk/app-debug.apk -p android features/login.feature --tags ~@dont_run

--> 

0 scenarios
3 steps (3 passed)

----------------------------------------------------------------------

calabash-android run ../android/app/build/outputs/apk/app-debug.apk -p android features/login.feature --tags ~@dont_run_feature

-->

0 scenarios
0 steps

----------------------------------------------------------------------

Where all scenarios in the file are tagged with @dont_run and the file itself is tagged with @dont_run_feature.

We have seen this in both calabash-android and calabash-ios.

Is our expectation wrong, or is calabash misbehaving?

Thanks,
--Carl




Brad Thompson

unread,
Apr 24, 2015, 1:55:47 PM4/24/15
to calabash...@googlegroups.com
hmm could this be to do with where your placing your @tags in the feature file?  I know you can place them above scenarios like

@dont_run_scenario
Scenario: This is a scenario

or you can put them at the top of the entire feature file.

just ideas not sure if that helps.

Brad

Sher Bhachu

unread,
Apr 24, 2015, 5:16:12 PM4/24/15
to calabash...@googlegroups.com
As Brad mentioned, you need to put any @ignore tags at the top of the Feature file, line 1.

Cucumber will run background steps if you tag only the Scenarios.

i.e. you need to do...

@ignore
Feature : Some Feature...

Background:
....

Scenario : Some Scenario

Stanley Kurdziel

unread,
Apr 24, 2015, 9:24:07 PM4/24/15
to calabash...@googlegroups.com
I work with Carl.  Turns out there's a behavior mismatch between cucumber-jvm and ruby cucumber in this regard.

Here's an example feature file:
Feature: Should the Background run if no Scenario runs?

  Background:
    Given no scenario runs, should the background?

  @manual
  Scenario: Scenario1
    Given This scenario should not run

  @manual
  Scenario: Scenario2
    Given This scenario should not run



If I run this with cucumber-jvm:

mvn test -Dcucumber.options="classpath:skeleton/my_first.feature --tags ~@manual"

I get the result:

0 Scenarios
0 Steps
0m0.000s

Tests run: 0, ...


That's where our expectation is coming from.  But with ruby, the same feature file comes back with a different result:

cucumber src/test/resources/skeleton/my_first.feature --tags ~@manual

0 scenarios
1 step (1 undefined)
0m0.006s

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

Given(/^no scenario runs, should the background\?$/) do
  pending # ...
end



Seems it's really a question of ruby cucumber vs cucumber-jvm =)

Thanks,
-Stan
Reply all
Reply to author
Forward
0 new messages