Package org.jbehave.core.mock

Examples of org.jbehave.core.mock.Mock


       
        ensureThat(exception, isNotNull());
    }
   
    public void shouldRethrowExceptionsInStepsAsVerificationExceptions() throws Exception {
        final Mock given = mock(GivenWithCleanUp.class, "given");
        given.expects("setUp").will(throwException(new Exception()));
       
        final Scenario scenario = new MultiStepScenario(){
            public void specifySteps() {
                given((Given) given);
            }};
View Full Code Here


       
        ensureThat(exception, isNotNull());       
    }
   
    public void shouldNotRethrowVerificationExceptionsInSteps() throws Exception {
        final Mock given = mock(GivenWithCleanUp.class, "given");
        VerificationException verificationException = new VerificationException("My message");
        given.expects("setUp").will(throwException(verificationException));
       
        final Scenario scenario = new MultiStepScenario(){
            public void specifySteps() {
                given((Given) given);
            }};
View Full Code Here

        ensureThat(exception, is(verificationException));       
    }
   
    public void shouldNotCleanUpIfNotRun() throws Exception {
        // given
        final Mock given = mock(GivenWithCleanUp.class, "given");
        World world = (World)stub(World.class);
       
        Scenario scenario = new MultiStepScenario() {
            public void specifySteps() {
                given((Given) given);
            }};
           
        given.expects("cleanUp").never();
           
        scenario.specify();
        scenario.cleanUp(world);
       
        verifyMocks();
View Full Code Here

        verifyMocks();
    }
   
    public void shouldNotCleanUpIfAlreadyCleanedUp() throws Exception {
        // given
        final Mock given = mock(GivenWithCleanUp.class, "given");
        World world = (World)stub(World.class);
       
        Scenario scenario = new MultiStepScenario() {
            public void specifySteps() {
                given((Given) given);
               
            }};
           
        given.expects("cleanUp").once();
           
        scenario.specify();
        scenario.run(world);
        scenario.cleanUp(world);
        scenario.cleanUp(world);
View Full Code Here

        verifyMocks();
    }
   
    public void shouldCleanUpEvenIfStepFailed() {
        // given
        final Mock given = mock(GivenWithCleanUp.class, "given");
        World world = (World)stub(World.class);
       
        Scenario scenario = new MultiStepScenario() {
            public void specifySteps() {
                given((Given) given);
               
            }};
           
        given.expects("setUp").will(throwException(new VerificationException("")));
        given.expects("cleanUp").once();
           
        scenario.specify();
       
        try {
            scenario.run(world);
View Full Code Here

* @author <a href="mailto:ekeogh@thoughtworks.com">Elizabeth Keogh</a>
*/
public class GivenScenarioBehaviour extends UsingMiniMock {
 
  public void shouldRunScenarioWithWorldWhenSetUp() throws Exception {
    Mock scenario = mock(Scenario.class);
        World world = (World) stub(World.class);
        scenario.expects("run").with(world);
               
        GivenScenario givenScenario = new GivenScenario((Scenario) scenario);
        givenScenario.setUp(world);
       
        verifyMocks();
View Full Code Here

       
        verifyMocks();
  }
   
    public void shouldCleanUpScenarioWhenCleanedUp() {
        Mock scenario = mock(Scenario.class);
        World world = (World) stub(World.class);
        scenario.expects("cleanUp").with(world);
               
        GivenScenario givenScenario = new GivenScenario((Scenario) scenario);
        givenScenario.cleanUp(world);
       
        verifyMocks();
View Full Code Here

    }
   
    public void shouldTellListenerWhenVerifySucceeds() throws Exception {
        // given...
        Object instance = new HasSuccessfulMethod();
        Mock listener = mock(BehaviourListener.class);
        Behaviour behaviour = createBehaviourMethod(instance, "shouldWork");
       
        // expect...
        listener.expects("gotResult").with(resultOfType(Result.SUCCEEDED));
       
        // when...
        behaviour.verifyTo((BehaviourListener) listener);
       
        // then...
View Full Code Here

    }
   
    public void shouldReportExceptionFromMethod() throws Throwable {
        // given
        Behaviour behaviour = createBehaviourMethod(new MethodThrowsException(), "shouldDoSomething");
        Mock listener = mock(BehaviourListener.class);
       
        // expect
        listener.expects("gotResult").with(resultContainingCheckedException());
       
        // when
        behaviour.verifyTo((BehaviourListener) listener);
       
        // then
View Full Code Here

    }
   
    public void shouldReportExceptionFromSetUp() throws Throwable {
        // given
        Behaviour behaviour = createBehaviourMethod(new SetUpThrowsException(), "shouldDoSomething");
        Mock listener = mock(BehaviourListener.class);
       
        // expect
        listener.expects("gotResult").with(resultContainingCheckedException());
       
        // when
        behaviour.verifyTo((BehaviourListener) listener);
       
        // then
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.