Title: [1071] sandbox/jbehave-web/web-waffle/src/test/java/org/jbehave/web/waffle/controllers: Cleared failure cause before each run.

Diff

Modified: sandbox/jbehave-web/web-waffle/src/main/java/org/jbehave/web/waffle/controllers/ScenarioContext.java (1070 => 1071)

--- sandbox/jbehave-web/web-waffle/src/main/java/org/jbehave/web/waffle/controllers/ScenarioContext.java	2009-02-09 23:28:58 UTC (rev 1070)
+++ sandbox/jbehave-web/web-waffle/src/main/java/org/jbehave/web/waffle/controllers/ScenarioContext.java	2009-02-09 23:46:52 UTC (rev 1071)
@@ -58,7 +58,11 @@
 		this.messages.clear();
 	}
 
-	public void setFailureCause(Throwable cause) {
+	public void clearFailureCause() {
+		this.cause = null;		
+	}
+	
+	public void runFailedFor(Throwable cause) {
 		this.cause = cause;
 	}
 
@@ -75,4 +79,5 @@
 		return ToStringBuilder.reflectionToString(this);
 	}
 
+
 }

Modified: sandbox/jbehave-web/web-waffle/src/main/java/org/jbehave/web/waffle/controllers/ScenarioController.java (1070 => 1071)

--- sandbox/jbehave-web/web-waffle/src/main/java/org/jbehave/web/waffle/controllers/ScenarioController.java	2009-02-09 23:28:58 UTC (rev 1070)
+++ sandbox/jbehave-web/web-waffle/src/main/java/org/jbehave/web/waffle/controllers/ScenarioController.java	2009-02-09 23:46:52 UTC (rev 1071)
@@ -50,10 +50,11 @@
 		if (isNotBlank(scenarioContext.getInput())) {
 			try {
 				outputStream.reset();
+				scenarioContext.clearFailureCause();
 				scenarioContext.clearMessages();
 				scenarioRunner.run(storyDefinition(), configuration, steps);
 			} catch (Throwable e) {
-				scenarioContext.setFailureCause(e);
+				scenarioContext.runFailedFor(e);
 				scenarioContext.addMessage(e.getMessage());
 			}
 			scenarioContext.setOutput(outputStream.toString());

Modified: sandbox/jbehave-web/web-waffle/src/test/java/org/jbehave/web/waffle/controllers/ScenarioControllerTest.java (1070 => 1071)

--- sandbox/jbehave-web/web-waffle/src/test/java/org/jbehave/web/waffle/controllers/ScenarioControllerTest.java	2009-02-09 23:28:58 UTC (rev 1070)
+++ sandbox/jbehave-web/web-waffle/src/test/java/org/jbehave/web/waffle/controllers/ScenarioControllerTest.java	2009-02-09 23:46:52 UTC (rev 1071)
@@ -2,6 +2,7 @@
 
 import static java.util.Arrays.asList;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import org.codehaus.waffle.menu.Menu;
 import org.jbehave.scenario.Configuration;
@@ -36,6 +37,8 @@
 		controller.getScenarioContext().setInput(scenarioInput);
 		controller.run();
 		assertEquals(scenarioOutput, controller.getScenarioContext().getOutput().trim());
+		assertEquals(0, controller.getScenarioContext().getMessages().size());
+		assertEquals("", controller.getScenarioContext().getFailureCauseAsString());
 	}
 
 	@Test
@@ -55,6 +58,7 @@
 		controller.run();
 		assertEquals(scenarioOutput, controller.getScenarioContext().getOutput().trim());
 		assertEquals(asList("Test failed"), controller.getScenarioContext().getMessages());
+		assertTrue(controller.getScenarioContext().getFailureCauseAsString().startsWith("java.lang.RuntimeException: Test failed"));
 	}
 	
 	public static class MySteps extends Steps {


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to