我想在调用特定的模拟方法时执行一些代码。
mock = EasyMock.createMock(ConListener.class);
// Record n Replay
mock.Connected();
mock.DataSent();
EasyMock.replay(mock);
sock = createCon(addr, mock)
// I want the send to be called only after the mock's Connected() is invoked.
sock.send("data");
有没有什么方法可以在调用模拟时执行调用操作?
mock.Connected().Invoke () //something like this?
到目前为止我所拥有的是
mock = EasyMock.createMock(ConListener.class);
// Record n Replay
mock.Connected();
mock.DataSent();
EasyMock.replay(mock);
CompletableFuture<Void> connected = new CompletableFuture<Void>();
sock = createCon(addr, new ConListener() {
public void Connected() {
mock.Connected();
connected.complete(null);
}
public void DataSent() { mock.DataSent(); }
});
connected.get()
sock.send("data");
想检查是否有更好、更干净的方法。
繁星coding
相关分类