Package org.jbehave.core.result

Source Code of org.jbehave.core.result.ResultBehaviour

/*
* Created on 07-Jan-2004
*
* (c) 2003-2004 ThoughtWorks
*
* See license.txt for licence details
*/
package org.jbehave.core.result;

import org.jbehave.core.exception.PendingException;
import org.jbehave.core.exception.VerificationException;
import org.jbehave.core.mock.UsingMatchers;



/**
* @author <a href="mailto:dan@jbehave.org">Dan North</a>
*/
public class ResultBehaviour extends UsingMatchers {
 
  private void verifyResult(final Result result, final Result.Type status, boolean succeeded, boolean failed, boolean pending) {
        ensureThat(result.status(), eq(status), "status");
        ensureThat(result.succeeded(), eq(succeeded), "succeeded");
        ensureThat(result.failed(), eq(failed), "failed");
        ensureThat(result.isPending(), eq(pending),"pending");
    }

    public void shouldHaveConsistentStateForSuccess() throws Exception {
        Result result = new Result("shouldSucceed", "Container", Result.SUCCEEDED);
        verifyResult(result, Result.SUCCEEDED, true, false, false);
    }

    public void shouldHaveConsistentStateForFailure() throws Exception {
        Result result = new Result("shouldFail", "Container", new VerificationException("oops"));
        verifyResult(result, Result.FAILED, false, true, false);
    }

    public void shouldHaveConsistentStateForPending() throws Exception {
        Result result = new Result("shouldBeImplemented", "Container", new PendingException("todo"));
        verifyResult(result, Result.PENDING, false, false, true);
    }
}
TOP

Related Classes of org.jbehave.core.result.ResultBehaviour

TOP
Copyright © 2018 www.massapi.com. 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.