📄 abstractexpectation.java
字号:
/* Copyright (c) 2000-2004 jMock.org
*/
package org.jmock.expectation;
import org.jmock.core.Verifiable;
abstract public class AbstractExpectation implements Verifiable, Expectation
{
protected boolean myFailureModeIsImmediate = true;
protected String myName;
private boolean myHasExpectations = false;
public AbstractExpectation( String name ) {
myName = name;
}
protected void assertEquals( String msg,
int expectedValue,
int actualValue ) {
assertEquals(msg, new Integer(expectedValue), new Integer(actualValue));
}
/**
* Due to junit Assert being a Singleton implemented with static methods, and java's
* unfortunate implementation of class methods (e.g. no late binding) it is
* necessary to re-implement this invokedMethod here instead of over-riding failNotEquals
*/
protected void assertEquals( String msg,
Object expectedValue,
Object actualValue ) {
if (!myHasExpectations) {
return;
}
if (expectedValue == null && actualValue == null) {
return;
}
if (expectedValue != null && expectedValue.equals(actualValue)) {
return;
}
junit.framework.Assert.fail(myName
+ " "
+ msg
+ "\nExpected: "
+ expectedValue
+ "\nReceived: "
+ actualValue);
}
abstract public void clearActual();
public boolean hasExpectations() {
return myHasExpectations;
}
public void setFailOnVerify() {
myFailureModeIsImmediate = false;
}
protected void setHasExpectations() {
clearActual();
myHasExpectations = true;
}
protected boolean shouldCheckImmediately() {
return myFailureModeIsImmediate && myHasExpectations;
}
public abstract void verify();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -