Issue Type: Improvement Improvement
Assignee: Unassigned
Components: Core
Created: 29/May/13 10:25 AM
Description:

In keeping with a more functional design (to prevent global mutable state) it would be nice to be able have some sort of "test context" shared between steps automatically by the test framework.

I imagine it working something like this:

@Given("we have a cat")
public void firstStep(TestContext testContext)

{ ImmutableCat cat = new ImmutableCat("Felix"); testContext.put("cat", cat); }

@When("the cat is fed")
public void secondStep(TestContext testContext)

{ ImmutableCat cat = testContext.get("cat"); ImmutableFood food = new Food("Whiskers", FoodType.Dry); ImmutableCat happyCat = cat.feed(food) // Makes cat happy testContext.replace("cat", happyCat); testContext.put("food", food); }

@Then("the cat is happy")
public void thirdStep(TestContext testContext)

{ ImmutableCat cat = testContext.get("cat"); assert(cat.getFeels == Feels.Happy, "Why didn't you feed the Cat?"); }

@Then("the cat ate dry food")
public void fourthStep(TestContext testContext)

{ ImmutableFood food = testContext.get("food"); assert(food.getFoodType == FoodType.Dry, "The Kitty only likes dry food"); }

Basically as the steps are called the test context builds up the state of the world from the previous step, and passes it to the next step. It would be nice if this happened automatically if, for example, any of the steps have a "TextContext" paramater defined.

By doing this it would avoid the need for global mutable state that can cause side effects between steps.

Please leave comments if you have any other questions. Feed your kitties.

Thanks.

Project: JBehave
Priority: Major Major
Reporter: Barrie McGuire
Original Estimate: 1 week
Remaining Estimate: 1 week
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Reply via email to