Package org.jbehave.core.mock

Examples of org.jbehave.core.mock.Mock


        verifyMocks();
    }
   
    public void shouldPerformOutcome() throws Exception {
        // given
        final Mock outcome = mock(Outcome.class);
        Scenario scenario = new MultiStepScenario() {
            public void specifySteps() {
                then((Outcome)outcome);
            }
        };
        scenario.specify();
        World world = new HashMapWorld();
       
        // expect
        outcome.expects("verify").with(world);
       
        // when
        scenario.run(world);
       
        // then
View Full Code Here


        verifyMocks();
    }
   
    public void shouldPerformStepsInCorrectOrder() {
        // given
        final Mock given = mock(Given.class);
        final Mock event = mock(Event.class);
        final Mock outcome = mock(Outcome.class);
        World world = new HashMapWorld();
       
        Scenario scenario = new MultiStepScenario() {
            public void specifySteps() {
                given((Given)given);
                when((Event)event);
                then((Outcome)outcome);
            }
        };
        scenario.specify();
       
        // expect
        given.expects("setUp").with(world);
        event.expects("occurIn").with(world).after(given, "setUp");
        outcome.expects("verify").with(world).after(event, "occurIn");
       
        // when
        scenario.run(world);
       
        // then
View Full Code Here

    }


    public void shouldTellStepsToCleanUpWorldInReverseOrder() throws Exception {
        // given
        final Mock given = mock(GivenWithCleanUp.class);
        final Mock event = mock(Event.class); // no cleanUp
        final Mock outcome = mock(OutcomeWithCleanUp.class);
        World world = new HashMapWorld();

        Scenario scenario = new MultiStepScenario() {
            public void specifySteps() {
                given((Given)given);
                when((Event)event);
                then((Outcome)outcome);
            }
        };
        scenario.specify();

        // expect
        outcome.expects("cleanUp").with(world);
        event.expects("cleanUp").never();
        given.expects("cleanUp").with(world).after(outcome, "cleanUp");

        // when
        scenario.run(world);
View Full Code Here

        verifyMocks();
    }
   
    public void shouldNarrateScenarioAndStepsInOrder() throws Exception {
        // given
        final Mock given = mock(Given.class);
        final Mock event = mock(Event.class);
        final Mock outcome = mock(Outcome.class);
        Mock renderer = mock(Renderer.class);
       
        Scenario scenario = new MultiStepScenario() {
            public void specifySteps() {
                given((Given)given);
                when((Event)event);
                then((Outcome)outcome);
            }
        };
        scenario.specify();
       
        // expect
        renderer.expects("renderScenario").with(scenario);
        given.expects("narrateTo").with(renderer).after(renderer, "renderScenario");
        event.expects("narrateTo").with(renderer).after(given, "narrateTo");
        outcome.expects("narrateTo").with(renderer).after(event, "narrateTo");
       
        // when
View Full Code Here

        verifyMocks();
    }
   
    public void shouldContainMocksIfAnyStepsContainMocks() throws Exception {
        // given
        final Mock given = mock(Given.class);
        final Mock event = mock(Event.class);
        final Mock outcome = mock(Outcome.class);
       
        // expect
        given.expects("containsMocks").will(returnValue(false));
        event.expects("containsMocks").will(returnValue(false));
        outcome.expects("containsMocks").will(returnValue(true)); // has mocks

        Scenario scenario = new MultiStepScenario() {
            public void specifySteps() {
                given((Given)given);
                when((Event)event);
View Full Code Here

        verifyMocks();
    }
   
    public void shouldSucceedFastIfAnyStepsContainMocks() throws Exception {
        // given
        final Mock given = mock(Given.class);
        final Mock event = mock(Event.class);
        final Mock outcome = mock(Outcome.class);
       
        // expect
        given.expects("containsMocks").will(returnValue(false));
        event.expects("containsMocks").will(returnValue(true)); // succeeds fast at second step
        outcome.expects("containsMocks").never();               // so third step not checked
       
        Scenario scenario = new MultiStepScenario() {
            public void specifySteps() {
                given((Given)given);
                when((Event)event);
View Full Code Here

        verifyMocks();
    }
   
    public void shouldNotContainMocksIfNoStepsContainMocks() throws Exception {
        // given
        final Mock given = mock(Given.class);
        final Mock event = mock(Event.class);
        final Mock outcome = mock(Outcome.class);
       
        // expect
        given.expects("containsMocks").will(returnValue(false));
        event.expects("containsMocks").will(returnValue(false));
        outcome.expects("containsMocks").will(returnValue(false));
       
        Scenario scenario = new MultiStepScenario() {
            public void specifySteps() {
                given((Given)given);
                when((Event)event);
View Full Code Here

        ensureThat(result, eq(false));
    }
   
    public void shouldCopyOutcomeWithExpectationsAfterLastGiven() throws Exception {
        // given
        final Mock given1 = mock(Given.class, "given1");
        final Mock given2 = mock(Given.class, "given2");
        final Mock event = mock(Event.class, "event");
        final Mock outcome = mock(OutcomeWithExpectations.class, "outcome");
        World world = (World)stub(World.class);
       
        Scenario scenario = new MultiStepScenario() {
            public void specifySteps() {
                given((Given) given1);
                given((Given) given2);
                when((Event) event);
                then((Outcome) outcome);
            }
        };
        scenario.specify();
       
        // expect
        given1.expects("setUp").with(world);
        given2.expects("setUp").with(world).after(given1, "setUp");
        outcome.expects("setExpectationsIn").with(world).after(given2, "setUp");
        event.expects("occurIn").with(world).after(outcome, "setExpectationsIn");
        outcome.expects("verify").with(world).after(event, "occurIn");
       
        // when
        scenario.run(world);
       
        // then
View Full Code Here

        verifyMocks();
    }
   
    public void shouldCopyOutcomeWithExpectationsAtBeginningIfThereAreNoGivens() throws Exception {
        // given
        final Mock event = mock(Event.class);
        final Mock outcome = mock(OutcomeWithExpectations.class, "outcome");
        World world = (World)stub(World.class);
       
        Scenario scenario = new MultiStepScenario() {
            public void specifySteps() {
                when((Event) event);
                then((Outcome) outcome);
            }
        };
        scenario.specify();
       
        // expect
        outcome.expects("setExpectationsIn").with(world);
        event.expects("occurIn").with(world).after(outcome, "setExpectationsIn");
        outcome.expects("verify").with(world).after(event, "occurIn");
       
        // when
        scenario.run(world);
       
        // then
View Full Code Here

        // then
        verifyMocks();
    }
   
    public void shouldSpecifyScenarioWhenAddingAsAGiven() {
        final Mock scenario = mock(Scenario.class);
        World world = (World)stub(World.class);
        scenario.expects("specify");
       
        Scenario parentScenario = new MultiStepScenario() {
            public void specifySteps() {
                given((Scenario)scenario);
            }
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.