【发布时间】:2015-07-03 10:34:32
【问题描述】:
foo.toString() 返回
"[id: <id>, stuffIdontCareAbout: 0]"
我想测试 id 是否正确,但字符串中的其他所有内容都可以有任何值。这是我尝试过的:
expect(foo.toString()).andReturn(EasyMock.find("[id: 42,"));
但它是这样抱怨的:
java.lang.IllegalStateException: 0 matchers expected, 1 recorded.
This exception usually occurs when matchers are mixed with raw values when recording a method:
foo(5, eq(6)); // wrong
You need to use no matcher at all or a matcher for every single param:
foo(eq(5), eq(6)); // right
foo(5, 6); // also right
那么,如何在返回值上使用 EasyMock 匹配器?
【问题讨论】:
-
我不明白。你在嘲笑
foo。foo.toString()将返回您告诉它返回的任何内容。 -
O.是啊,你说得对。谢谢!