I think the real answer to this is "our scenarios shouldn't be dependent" but until then we are chaining scenarios that need to run in order and we sometimes need to pass data from one to another. For now I've created a small registry class with static methods and variables that can be used to persist data from between scenarios in a single behat run.

We should get feedback from the behat community on how this really should be done (or if it really shouldn't be).

Comments

tizzo’s picture

eliza411’s picture

Version: » 6.x-1.x-dev
Component: Tests » Failing test
Status: Active » Fixed

The real answer to this from weaverryan is that scenarios shouldn't be dependent, but we're in a position where they are, so we'll be living with the hacky data registry indefinitely.

http://drupalcode.org/project/doobie.git/commit/d8aa8dc

JohnBBrookes’s picture

I am just looking for a solution to this same problem - in zend framework rather than Drupal - but I thought I would support you by explaining what I am trying to do.

Suppose we have a user account service. You create the account, confirm it, log in, update the account, and log out. I have scenarios for each of these actions, so I can test different routes through the service.

Obviously, if one scenario fails I do not want the others to run, but I do not want to have to duplicate the code several times (by creating a scenario for each route to be tested) and I want to keep the scenarios written in behat rather than converting them into steps, so the customer can validate the flow.

I can do these quite easily in other environments (eg SoapUi or PHPUnit), but I am finding Behat very limited in these areas.

Does anybody have any suggestions for getting round this without creating dependent scenarios?

Regards
John

eliza411’s picture

Assigned: tizzo » Unassigned

This should really be its own support request, open and active, but have you explored http://docs.behat.org/guides/2.definitions.html#step-execution-chaining

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

zuernbernhard’s picture

Issue summary: View changes

The Problem still persists. I Agree that it should be a Support Request. So why is it closed ? This "@dependent"-Tagging only works for the drupal.org-Build-process ? https://www.drupal.org/node/1780048 I cannot get it to work in my own setup. So it doesn't matter if I tag my scenarios with @dependent or not. If i use a first scenario to create a node i cannot use this node in my second scenario in the same feature file because all content from the temp-user is already deleted.

zuernbernhard’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Closed (fixed) » Needs work
Mixologic’s picture

Status: Needs work » Closed (won't fix)

Sorry @zuernBernhard - this is totally the wrong issue queue for this feature. The doobie project is *only* for the BDD tests that run against drupal.org. If this problem is going to be solved somewhere, its going to be either in the drupal extention project, or in behat itself. The maintainers of this issue queue dont have the ability to implement this feature.