Title: [jbehave] [614] trunk/core/src/java/jbehave/core/story/domain: Removed Scenarios - merged functionality in ScenarioDrivenStory.
Revision 614
Author mauro
Date 2006-12-05 07:05:03 -0600 (Tue, 05 Dec 2006)
Log Message
Removed Scenarios - merged functionality in ScenarioDrivenStory.
Modified Paths
trunk/core/src/behaviour/jbehave/core/story/domain/ScenarioDrivenStoryBehaviour.java
trunk/core/src/java/jbehave/core/story/domain/ScenarioDrivenStory.java
trunk/core/src/java/jbehave/core/story/renderer/PlainTextRenderer.java
trunk/core/src/java/jbehave/core/story/renderer/Renderer.java
Removed Paths
trunk/core/src/behaviour/jbehave/core/story/domain/ScenariosBehaviour.java
trunk/core/src/java/jbehave/core/story/domain/Scenarios.java
Diff
Modified: trunk/core/src/behaviour/jbehave/core/story/domain/ScenarioDrivenStoryBehaviour.java (613 => 614)
--- trunk/core/src/behaviour/jbehave/core/story/domain/ScenarioDrivenStoryBehaviour.java 2006-12-05 12:30:33 UTC (rev 613)
+++ trunk/core/src/behaviour/jbehave/core/story/domain/ScenarioDrivenStoryBehaviour.java 2006-12-05 13:05:03 UTC (rev 614)
@@ -7,6 +7,8 @@
*/
package jbehave.core.story.domain;
+import jbehave.core.exception.NestedVerificationException;
+import jbehave.core.exception.VerificationException;
import jbehave.core.listener.BehaviourListener;
import jbehave.core.minimock.UsingMiniMock;
import jbehave.core.mock.Expectation;
@@ -60,6 +62,70 @@
verifyMocks();
}
+public void shouldInformListenersOfScenarioUsingMocks() {
+World world = (World) stub(World.class);
+Narrative narrative = new Narrative(,,);
+AStory story = new AStory(narrative);
+
+Mock listener = mock(BehaviourListener.class);
+AScenario scenario = new AScenario();
+ScenarioResult result = new ScenarioResult(a scenario, a story, ScenarioResult.USED_MOCKS);
+
+scenario.expects(run).with(world);
+scenario.expects(containsMocks).will(returnValue(true));
+listener.expects(gotResult).with(eq(result));
+
+story.addScenario((Scenario)scenario);
+story.addListener((BehaviourListener)listener);
+
+story.run(world);
+
+verifyMocks();
+}
+
+public void shouldInformListenersOfScenarioFailure() {
+World world = (World) stub(World.class);
+Narrative narrative = new Narrative(,,);
+AStory story = new AStory(narrative);
+
+Mock listener = mock(BehaviourListener.class);
+AScenario scenario = new AScenario();
+NestedVerificationException nve = new NestedVerificationException(new RuntimeException());
+ScenarioResult result = new ScenarioResult(a scenario, a story, nve);
+scenario.expects(run).with(world).will(throwException(nve));
+listener.expects(gotResult).with(eq(result));
+
+story.addScenario((Scenario)scenario);
+story.addListener((BehaviourListener)listener);
+
+story.run(world);
+
+verifyMocks();
+}
+
+public void shouldCleanUpScenariosEvenIfVerificationFails() {
+World world = (World) stub(World.class);
+Narrative narrative = new Narrative(,,);
+AStory story = new AStory(narrative);
+
+Mock listener = mock(BehaviourListener.class);
+AScenario scenario = new AScenario();
+VerificationException ve = new VerificationException(Thrown by an outcome when an ensureThat fails);
+ScenarioResult result = new ScenarioResult(a scenario, a story, ve);
+scenario.expects(run).with(world).will(throwException(ve));
+scenario.expects(cleanUp).with(world);
+
+story.addScenario((Scenario)scenario);
+
+try {
+story.run(world);
+} catch (VerificationException e) {
+// Expected, but AFTER cleanUp.
+}
+
+verifyMocks();
+}
+
private class AStory extends ScenarioDrivenStory {
// just used to provide the story name
Deleted: trunk/core/src/behaviour/jbehave/core/story/domain/ScenariosBehaviour.java (613 => 614)
--- trunk/core/src/behaviour/jbehave/core/story/domain/ScenariosBehaviour.java 2006-12-05 12:30:33 UTC (rev 613)
+++ trunk/core/src/behaviour/jbehave/core/story/domain/ScenariosBehaviour.java 2006-12-05 13:05:03 UTC (rev 614)
@@ -1,137 +0,0 @@
-package jbehave.core.story.domain;
-
-import jbehave.core.exception.NestedVerificationException;
-import jbehave.core.exception.VerificationException;
-import jbehave.core.listener.BehaviourListener;
-import jbehave.core.minimock.UsingMiniMock;
-import jbehave.core.mock.Expectation;
-import jbehave.core.mock.Mock;
-import jbehave.core.story.renderer.Renderer;
-import jbehave.core.story.result.ScenarioResult;
-
-public class ScenariosBehaviour extends UsingMiniMock {
-
- public void shouldRunAndTidyUpScenariosInOrder() {
-AScenario scenarioA = new