Forum: RSpec Skipping the testscenario based on Given block execution.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Anil G. (Guest)
on 2009-05-18 19:36
Hi,
Generally in cucumber, we write the preconditions in GIVEN block,
Is there any way in cucumber using which test scenario execution is
skipped, based on the Given block execution.
Because there is no point in executing the test scenario when
precondition itself fails.

Please help me in this regard
Lee H. (Guest)
on 2009-05-18 22:49
(Received via mailing list)
Anil,
 Your precondition shouldn't fail?

- Lee

2009/5/18 Anil G. <removed_email_address@domain.invalid>
Anil G. (Guest)
on 2009-05-19 12:30
Hi,
I think i am not clear.
My query is while running the testcases,
Some times precondition of testcase fails, when precondition itself
fails there is no point in executing the testcase further.
so , is there any way in cucumber to skip execution of scenario when
precondition of testcase fails.

Thanks,
Anil
Aslak H. (Guest)
on 2009-05-19 13:57
(Received via mailing list)
> Hi,
> I think i am not clear.
> My query is while running the testcases,
> Some times precondition of testcase fails, when precondition itself
> fails there is no point in executing the testcase further.
> so , is there any way in cucumber to skip execution of scenario when
> precondition of testcase fails.
>

The intention is that when a Before block raises an error, the steps
of the scenario are skipped. However, this isn't working properly, but
a fix is in progress:
https://rspec.lighthouseapp.com/projects/16211/tic...

For new threads, please use the Cucumber google group:
http://groups.google.com/group/cukes

Cheers,
Aslak
Joseph W. (Guest)
on 2009-05-19 14:46
(Received via mailing list)
Anil G. wrote:
> Hi,
> I think i am not clear.
> My query is while running the testcases,
> Some times precondition of testcase fails, when precondition itself
> fails there is no point in executing the testcase further.
> so , is there any way in cucumber to skip execution of scenario when
> precondition of testcase fails.
>
In a Scenario if any step fails the following steps of that scenario
are skipped.

This is the current behaviour of Cucumber.  Older versions of Cucumber
had some trouble with properly skipping these steps.

HTHs
--
Joseph W.
http://blog.josephwilk.net
Denis H. (Guest)
on 2009-05-19 15:04
(Received via mailing list)
This seems like a really bad practice when writing tests, and I'm having
trouble imagining a situation where this would be justified.

If "sometimes the precondition fails" that means on each test run you
won't know whether the test actually ran or not, and thus whether the
test succeeds or fails.

Seems to me this really needs 2 examples: 1 for when the precondition
succeeds, 1 for when it fails.  What is the source of this
precondition?  Sounds like that needs to be stubbed or mocked.

As always, I would be happy for others to set me back on track...
Thanks,

dwh
This topic is locked and can not be replied to.