Package org.jbehave.core.mock

Examples of org.jbehave.core.mock.Mock


        };
    }
   
    public void shouldVerifySingleBehaviourMethod() throws Exception {
        // given
        Mock listener = mock(BehaviourListener.class);
        final Behaviour[] capturedBehaviour = new Behaviour[1]; // the behaviour
       
        BehaviourVerifier verifier = new BehaviourVerifier(null) { // hand-rolled mock for concrete class
            public void verifyBehaviour(Behaviour behaviour) {
                capturedBehaviour[0] = behaviour;
View Full Code Here


        public void shouldDoAnotherThing() {}
    }
   
    public void shouldVerifyMultipleBehaviourMethods() throws Exception {
        // given
        Mock listener = mock(BehaviourListener.class);
        Behaviour behaviour = new BehaviourClass(
                ClassWithTwoBehaviourMethods.class, new BehaviourVerifier((BehaviourListener) listener));
       
        // expect
        listener.expects("gotResult").with(successfulResultFromMethodCalled("shouldDoOneThing"));
        listener.expects("gotResult").with(successfulResultFromMethodCalled("shouldDoAnotherThing"));
       
        // when
        behaviour.verifyTo((BehaviourListener) listener);
       
        // then
View Full Code Here

        }
    }
   
    public void shouldVerifyNestedBehaviourClasses() throws Exception {
        // given
        Mock listener = mock(BehaviourListener.class);
        Behaviour behaviour = new BehaviourClass(
                ClassWithNestedClasses.class, new BehaviourVerifier((BehaviourListener) listener));
       
        // expect
        listener.expects("gotResult").with(successfulResultFromMethodCalled("shouldDoSomething1"));
        listener.expects("gotResult").with(successfulResultFromMethodCalled("shouldDoSomething2"));
       
        // when
        behaviour.verifyTo((BehaviourListener) listener);
       
        // then
View Full Code Here

        }
    }
   
    public void shouldVerifyDeeplyNestedBehaviourClasses() throws Exception {
        // given
        Mock listener = mock(BehaviourListener.class);
        Behaviour behaviour = new BehaviourClass(
                ClassWithDeeplyNestedClasses.class, new BehaviourVerifier((BehaviourListener) listener));
       
        // expect
        listener.expects("gotResult").with(successfulResultFromMethodCalled("shouldDoSomething1"));
        listener.expects("gotResult").with(successfulResultFromMethodCalled("shouldDoSomething2"));
       
        // when
        behaviour.verifyTo((BehaviourListener) listener);
       
        // then
View Full Code Here

        public void dontRunMe() {}
    }
   
    public void shouldIgnorePublicMethodsThatDontStartWithShould() throws Exception {
        // given
        Mock listener = mock(BehaviourListener.class);
        Behaviour behaviour = new BehaviourClass(HasNoBehaviourMethods.class, nullVerifier);
       
        // expect
        listener.expects("gotResult").never();
       
        // when
        behaviour.verifyTo((BehaviourListener) listener);
       
        // then
View Full Code Here

        protected void shouldNotRunMe() {}
    }
   
    public void shouldIgnoreNonPublicMethodsThatStartWithShould() throws Exception {
        // given
        Mock listener = mock(BehaviourListener.class);
        Behaviour behaviour = new BehaviourClass(HasNonPublicBehaviourMethod.class, nullVerifier);
       
        // expect
        listener.expects("gotResult").never();
       
        // when
        behaviour.verifyTo((BehaviourListener) listener);
       
        // then
View Full Code Here

            protected World createWorld() {
                return world;
            }
        };
       
        Mock listener = mock(BehaviourListener.class);
        AScenario scenario = new AScenario();
        ScenarioResult result = new ScenarioResult("a scenario", "a story", Result.SUCCEEDED);
       
        scenario.expects("run").with(world);
        scenario.expects("containsMocks").will(returnValue(false));
        listener.expects("gotResult").with(eq(result));
       
        story.addScenario((Scenario)scenario);
        story.addListener((BehaviourListener)listener);
        story.run();
       
View Full Code Here

            protected World createWorld() {
                return world;
            }
        };
       
        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();
View Full Code Here

            protected World createWorld() {
                return world;
            }
        };
       
        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();
View Full Code Here

            protected World createWorld() {
                return world;
            }
        };
       
        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);
View Full Code Here

TOP

Related Classes of org.jbehave.core.mock.Mock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.