|
按照easymock的文档写了一个简单的例子,竟然报错:
import static org.easymock.EasyMock.*;
import junit.framework.TestCase;
public class ParserTest extends TestCase {
private Parser parser;
private SynFilter mock;
private String text = "计算机";
public static void main(String[] args) {
junit.textui.TestRunner.run(ParserTest.class);
}
protected void setUp() throws Exception {
super.setUp();
mock = createMock(SynFilter.class);
parser = new Parser();
parser.setFilter(mock);
}
protected void tearDown() throws Exception {
super.tearDown();
}
/*
* Test method for 'Parser.parse(String)'
*/
public void testParse() {
mock.getSynonym("计算机");
replay(mock);
parser.parse("计算机");
verify(mock);
}
}
There was 1 error:
1) testParse(ParserTest)java.lang.IllegalStateException: missing behavior definition for the preceeding method call getSynonym("计算机")
at org.easymock.internal.MocksControl.replay(MocksControl.java:61)
at org.easymock.EasyMock.replay(EasyMock.java:1280)
at ParserTest.testParse(ParserTest.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at ParserTest.main(ParserTest.java:10) |
|