Java 在两个不同的模拟调用中期望相同对象的习惯用法

Java 在两个不同的模拟调用中期望相同对象的习惯用法,java,easymock,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(); ass

假设我有以下代码

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());
但这不起作用,因为在设置时,
a1
显然还没有捕获的值

是否有任何匹配器或其他机制可以让我在适当的时候设置期望?创建这两个捕获并对它们进行断言对于这个特定场景来说感觉太过分了

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