Re: [jbehave-dev] Re: [jbehave-scm] [jbehave] [612] trunk/core/src/java/jbehave/core: [dn] replaced constraint with matcher throughout (except in JMockSugar because I can't)

2006-12-05 Thread Shane Duan

Ah.  Thanks for the explanation.

Are we going to add it now?  In this way, people who are using Java5
can use this style right now.

On 12/5/06, Dan North [EMAIL PROTECTED] wrote:

That's what I meant - sorry, didn't explain it very well.

In Ensure we will have pairs of methods, called that(...) and
ensureThat(...) for each signature. That way, 1.4 folks can do
Ensure.that(...), and 1.5 people can statically import Ensure and use
ensureThat(...).



--
Shane
http://www.shaneduan.com

-
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email



[jbehave-scm] [jbehave] [613] trunk: Removed redundant method in Scenario - already in super interface HasCleanUp.

2006-12-05 Thread mauro
Title: [jbehave] [613] trunk: Removed redundant method in Scenario - already in super interface HasCleanUp.







Revision 613
Author mauro
Date 2006-12-05 06:30:33 -0600 (Tue, 05 Dec 2006)


Log Message
Removed redundant method in Scenario - already in super interface HasCleanUp.

Modified Paths

trunk/.classpath
trunk/core/src/java/jbehave/core/story/domain/Scenario.java




Diff

Modified: trunk/.classpath (612 => 613)

--- trunk/.classpath	2006-12-05 08:42:05 UTC (rev 612)
+++ trunk/.classpath	2006-12-05 12:30:33 UTC (rev 613)
@@ -1,11 +1,11 @@
 ?xml version=1.0 encoding=UTF-8?
 classpath
 	classpathentry kind=src path=core/src/java/
-	classpathentry kind=src path=extensions/classmocks/src/behaviour/
-	classpathentry kind=src path=extensions/classmocks/src/java/
 	classpathentry kind=src path=core/src/behaviour/
 	classpathentry kind=src path=extensions/ant/src/java/
 	classpathentry kind=src path=extensions/ant/src/behaviour/
+classpathentry kind=src path=extensions/classmocks/src/behaviour/
+classpathentry kind=src path=extensions/classmocks/src/java/
 	classpathentry kind=src path=extensions/fit/src/java/
 	classpathentry kind=src path=extensions/fit/src/test/
 	classpathentry kind=src path=extensions/jmock/src/java/


Modified: trunk/core/src/java/jbehave/core/story/domain/Scenario.java (612 => 613)

--- trunk/core/src/java/jbehave/core/story/domain/Scenario.java	2006-12-05 08:42:05 UTC (rev 612)
+++ trunk/core/src/java/jbehave/core/story/domain/Scenario.java	2006-12-05 12:30:33 UTC (rev 613)
@@ -33,5 +33,4 @@
 void assemble();
 void run(World world);
 boolean containsMocks();
-void cleanUp(World world);
 }
\ No newline at end of file










To unsubscribe from this list please visit:


http://xircles.codehaus.org/manage_email



[jbehave-scm] [jbehave] [614] trunk/core/src/java/jbehave/core/story/domain: Removed Scenarios - merged functionality in ScenarioDrivenStory.

2006-12-05 Thread mauro
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 

Re: [jbehave-dev] simplicating scenarios

2006-12-05 Thread Mauro Talevi

Joe Walnes wrote:



Just to clarify - is the scope of assemble() to avoid big constructors
or is there another usecase for it? 



That's definitely one of the reasons.

Another is to allow the API to evolve over time without necessarily 
breaking people's code when a new dependency is added to the scenarios. 
It separates the framework related initialization from the user related 
initialization. 


ok - it works well for that use.

Kind of orthogonal to that is the super() style of initalization. This 
is very restricting because you can't do much before super, which often 
leads down the path of having lots of static helper functions and 
initialization blocks. Can get messy quickly.


Though I have to admit, I'd prefer the method to be called something 
like specify() instead of assemble().




To read:  'to specify a scenario' instead of 'to assemble a scenario'?

I guess it reads better :-)



-
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email