在两个不同的模拟调用中期望同一个对象的成语

时间:2016-09-26 10:55:53

标签: java easymock

假设我有以下代码

Capture<A> a1 = new Capture<A>();
Capture<A> a2 = new Capture<A>();

expect(mock.call1(capture(a1)).andReturn(...);
expect(mock.call2(capture(a2)).andReturn(...);

replayAll();

//Stuff to be tested

verifyAll();

assertEquals(a1.getValue(), a2.getValue());

我并不真正关心它们之外的捕获内容是否相同。我想做的是

expect(mock.call2(eq(a1.getValue())))

但这不起作用,因为在设置时,a1显然没有捕获的值。

我是否可以申请任何匹配或其他机制,以便我在适当的时间设定期望?创建两个捕获并在它们上面断言对于这个特定的场景来说感觉非常难以理解......

0 个答案:

没有答案
相关问题