This stub is wrong :
doNothing().when(mockObject.methodToStub(captor.capture())); // wrong
methodToStub(...)
must be outside the when
if using this API style (it should only contain the mock) :
doNothing().when(mockObject).methodToStub(captor.capture()); // correct
Tho remarks however :
doNothing
is the default for void methods for a mock.
- You can use the
BDDMockito
aliases that enables your code to be real à la Behavior Driven Development
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…