mardi 7 avril 2015

Capture Arguments from Chained Methods Using Mockito

I'm writing some Java unit tests for an existing class using Mockito. However, I'm having trouble extracting the arguments with which an object of this class is calling a method as part of a nested call.


Example:



public class SomeClass {

public SomeClass() {
//...
}

public someMethod(Foo foo) {
// Bar bar = ...
someOtherMethod(bar);
}

private someOtherMethod(Bar bar) {
//...
}
}


I want to capture the arguments to someOtherMethod() and verify that bar is what it should be. Can I do this using ArgumentCaptor or other functionality within Mockito?


Aucun commentaire:

Enregistrer un commentaire