📄 expectationdoublevaluetest.java
字号:
/* Copyright (c) 2000-2004 jMock.org
*/
package test.jmock.expectation;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import org.jmock.expectation.AssertMo;
import org.jmock.expectation.ExpectationDoubleValue;
public class ExpectationDoubleValueTest extends TestCase
{
private ExpectationDoubleValue myExpectation =
new ExpectationDoubleValue("ExpectationDoubleValue for testing");
public void testExpectNothing() {
myExpectation.setExpectNothing();
assertTrue("Should have an expectation",
myExpectation.hasExpectations());
}
public void testExpectNothingFail() {
myExpectation.setExpectNothing();
try {
myExpectation.setActual(100.0);
fail("Should fail fast");
}
catch (AssertionFailedError ex) {
// expected
}
}
public void testFailOnVerify() {
myExpectation.setExpected(0.0, 0.0);
myExpectation.setFailOnVerify();
myExpectation.setActual(1.0);
AssertMo.assertVerifyFails(myExpectation);
}
public void testFlushActual() {
myExpectation.setActual(10);
myExpectation.setExpectNothing();
myExpectation.verify();
}
public void testHasNoExpectations() {
myExpectation.setActual(0.0);
assertTrue("Has no expectations",
!myExpectation.hasExpectations());
}
public void testFailOutsideError() {
myExpectation.setExpected(100.0, 1.0);
try {
myExpectation.setActual(102.0);
fail("Should fail fast on double");
}
catch (AssertionFailedError ex) {
//expected
}
}
public void testPassOnError() {
myExpectation.setExpected(100.0, 1.0);
myExpectation.setActual(101.0);
myExpectation.verify();
}
public void testPassWithinError() {
myExpectation.setExpected(100.0, 1.0);
myExpectation.setActual(100);
myExpectation.verify();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -