-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
8000
I was looking at a memory leak caused by a mock in our tests and I noticed that creating a mock this way
Foo foo = mock(Foo.class, withSettings().stubOnly());
will still keep the last invocation in memory:
I was wondering if that was on purpose? I thought the whole point of stubOnly()
was to prevent allocating too much memory for nothing by preventing verify()
on a mock. I think something like that would make more sense:
public class EmptyRegisteredInvocation implements RegisteredInvocations, Serializable {
public void add(Invocation invocation) {
// do nothing
}
public void removeLast() {
// do nothing
}
public List<Invocation> getAll() {
return Collections.emptyList();
}
public boolean isEmpty() {
return true;
}
}